You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/03/16 14:38:33 UTC

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

[LOG4J2-63] Support configuration from version 1.x log4j.properties.
Partial support for TTCC layout (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/d6c916bb
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d6c916bb
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d6c916bb

Branch: refs/heads/LOG4J2-1278-gc-free-logger
Commit: d6c916bbc4f417dc67982724f90a62d660dcc169
Parents: 1ecb8ec
Author: ggregory <gg...@apache.org>
Authored: Wed Mar 9 00:48:48 2016 -0800
Committer: ggregory <gg...@apache.org>
Committed: Wed Mar 9 00:48:48 2016 -0800

----------------------------------------------------------------------
 .../log4j/config/Log4j1ConfigurationFactory.java  |  6 ++++++
 .../config/Log4j1ConfigurationFactoryTest.java    |  6 ++++++
 .../log4j-console-TTCCLayout.properties           | 18 ++++++++++++++++++
 3 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d6c916bb/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 0e5d8d6..4dcad77 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
@@ -54,6 +54,7 @@ import org.apache.logging.log4j.status.StatusLogger;
  * <li>Target</li>
  * <li>layout = org.apache.log4j.PatternLayout</li>
  * <li>layout = org.apache.log4j.SimpleLayout</li>
+ * <li>layout = org.apache.log4j.TTCCLayout (partial)</li>
  * <li>layout = org.apache.log4j.HtmlLayout (partial)</li>
  * <li>layout = org.apache.log4j.XmlLayout (partial)</li>
  * <li>layout.ConversionPattern</li>
@@ -115,6 +116,11 @@ public class Log4j1ConfigurationFactory extends ConfigurationFactory {
                 appenderBuilder.add(newPatternLayout(builder, "%level - %m%n"));
                 break;
             }
+            case "org.apache.log4j.TTCCLayout": {
+                // TODO We do not have a %d for the time since the start of the app?
+                appenderBuilder.add(newPatternLayout(builder, "%d{UNIX_MILLIS} [%threadName] %level %logger - %m%n"));
+                break;
+            }
             case "org.apache.log4j.HTMLLayout": {
                 appenderBuilder.add(builder.newLayout("HtmlLayout"));
                 break;

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d6c916bb/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 c31fe37..013bb74 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
@@ -69,6 +69,12 @@ public class Log4j1ConfigurationFactoryTest {
     }
 
     @Test
+    public void testConsoleTtccLayout() throws Exception {
+        final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-TTCCLayout.properties");
+        Assert.assertEquals("%d{UNIX_MILLIS} [%threadName] %level %logger - %m%n", layout.getConversionPattern());
+    }
+
+    @Test
     public void testConsoleXmlLayout() throws Exception {
         final Layout<?> layout = testConsole("config-1.2/log4j-console-XmlLayout.properties");
         Assert.assertTrue(layout instanceof XmlLayout);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d6c916bb/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties
----------------------------------------------------------------------
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties
new file mode 100644
index 0000000..d6bd829
--- /dev/null
+++ b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties
@@ -0,0 +1,18 @@
+###############################################################################
+#
+# 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.TTCCLayout
+
+log4j.logger.com.example.foo = DEBUG