You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/03/09 09:57:49 UTC

logging-log4j2 git commit: [LOG4J2-63] Support configuration from version 1.x log4j.properties. Partial support for EnhancedPatternLayout (defaults only).

Repository: logging-log4j2
Updated Branches:
  refs/heads/master d6c916bbc -> 0d2cfbe90


[LOG4J2-63] Support configuration from version 1.x log4j.properties.
Partial support for EnhancedPatternLayout (defaults only).

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0d2cfbe9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0d2cfbe9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0d2cfbe9

Branch: refs/heads/master
Commit: 0d2cfbe90fad7f580e6aa1a4d87c4a0855f14610
Parents: d6c916b
Author: ggregory <gg...@apache.org>
Authored: Wed Mar 9 00:57:46 2016 -0800
Committer: ggregory <gg...@apache.org>
Committed: Wed Mar 9 00:57:46 2016 -0800

----------------------------------------------------------------------
 .../log4j/config/Log4j1ConfigurationFactory.java |  4 ++++
 .../config/Log4j1ConfigurationFactoryTest.java   |  6 ++++++
 ...og4j-console-EnhancedPatternLayout.properties | 19 +++++++++++++++++++
 3 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0d2cfbe9/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
index 4dcad77..fc07c1c 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1ConfigurationFactory.java
@@ -112,6 +112,10 @@ public class Log4j1ConfigurationFactory extends ConfigurationFactory {
                 appenderBuilder.add(newPatternLayout(builder, cpValue));
                 break;
             }
+            case "org.apache.log4j.EnhancedPatternLayout": {
+                appenderBuilder.add(newPatternLayout(builder, cpValue));
+                break;
+            }
             case "org.apache.log4j.SimpleLayout": {
                 appenderBuilder.add(newPatternLayout(builder, "%level - %m%n"));
                 break;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0d2cfbe9/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
index 013bb74..3212db0 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/Log4j1ConfigurationFactoryTest.java
@@ -51,6 +51,12 @@ public class Log4j1ConfigurationFactoryTest {
     }
 
     @Test
+    public void testConsoleEnhancedPatternLayout() throws Exception {
+        final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-EnhancedPatternLayout.properties");
+        Assert.assertEquals("%d{ISO8601} [%t][%c] %-5p: %m%n", layout.getConversionPattern());
+    }
+
+    @Test
     public void testConsoleHtmlLayout() throws Exception {
         final Layout<?> layout = testConsole("config-1.2/log4j-console-HtmlLayout.properties");
         Assert.assertTrue(layout instanceof HtmlLayout);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0d2cfbe9/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties
new file mode 100644
index 0000000..ab61518
--- /dev/null
+++ b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties
@@ -0,0 +1,19 @@
+###############################################################################
+#
+# Log4J 1.2 Configuration.
+#
+
+log4j.rootLogger=TRACE, Console
+
+##############################################################################
+#
+# The Console log
+#
+
+log4j.appender.Console=org.apache.log4j.ConsoleAppender
+log4j.appender.Console.ImmediateFlush=false
+log4j.appender.Console.Target=System.err
+log4j.appender.Console.layout=org.apache.log4j.EnhancedPatternLayout
+log4j.appender.Console.layout.ConversionPattern=%d{ISO8601} [%t][%c] %-5p: %m%n
+
+log4j.logger.com.example.foo = DEBUG