logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1505102 - in /logging/log4j/log4j2/trunk: core/src/main/java/org/apache/logging/log4j/core/appender/routing/ core/src/test/java/org/apache/logging/log4j/core/appender/routing/ core/src/test/resources/ src/changes/
Date Sat, 20 Jul 2013 07:21:14 GMT
Author: rgoers
Date: Sat Jul 20 07:21:13 2013
New Revision: 1505102

URL: http://svn.apache.org/r1505102
Log:
LOG4J2-166 - RoutingAppender's default Route can now be an appender reference.

Added:
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java
      - copied, changed from r1505096, logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
    logging/log4j/log4j2/trunk/core/src/test/resources/log4j-routing3.xml
      - copied, changed from r1505096, logging/log4j/log4j2/trunk/core/src/test/resources/log4j-routing.xml
Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java?rev=1505102&r1=1505101&r2=1505102&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
Sat Jul 20 07:21:13 2013
@@ -132,6 +132,10 @@ public final class RoutingAppender<T ext
         }
         if (route == null) {
             route = defaultRoute;
+            control = appenders.get(DEFAULT_KEY);
+            if (control != null) {
+                return control;
+            }
         }
         if (route != null) {
             final Appender<T> app = createAppender(route, event);

Copied: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java
(from r1505096, logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java)
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java?p2=logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java&p1=logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java&r1=1505096&r2=1505102&rev=1505102&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingDefaultAppenderTest.java
Sat Jul 20 07:21:13 2013
@@ -21,11 +21,11 @@ import org.apache.logging.log4j.LogManag
 import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
 import org.apache.logging.log4j.message.StructuredDataMessage;
 import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -40,8 +40,8 @@ import static org.junit.Assert.assertTru
 /**
  *
  */
-public class RoutingAppenderTest {
-    private static final String CONFIG = "log4j-routing.xml";
+public class RoutingDefaultAppenderTest {
+    private static final String CONFIG = "log4j-routing3.xml";
     private static Configuration config;
     private static ListAppender<LogEvent> app;
     private static LoggerContext ctx;
@@ -58,7 +58,7 @@ public class RoutingAppenderTest {
                 break;
             }
         }
-        final File file = new File("target/rolling1/rollingtest-Unknown.log");
+        final File file = new File("target/rolling1/routingtest.log");
         file.delete();
     }
 
@@ -67,7 +67,7 @@ public class RoutingAppenderTest {
         System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
         ctx.reconfigure();
         StatusLogger.getLogger().reset();
-        final File file = new File("target/rolling1/rollingtest-Unknown.log");
+        final File file = new File("target/rolling1/routingtest.log");
         file.delete();
     }
 
@@ -80,11 +80,7 @@ public class RoutingAppenderTest {
         assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size()
== 1);
         msg = new StructuredDataMessage("Test", "This is a test", "Alert");
         EventLogger.logEvent(msg);
-        File file = new File("target/routing1/routingtest-Alert.log");
+        File file = new File("target/routing1/routingtest.log");
         assertTrue("Alert file was not created", file.exists());
-        msg = new StructuredDataMessage("Test", "This is a test", "Activity");
-        EventLogger.logEvent(msg);
-        file = new File("target/routing1/routingtest-Activity.log");
-        assertTrue("Activity file was not created", file.exists());
     }
 }

Copied: logging/log4j/log4j2/trunk/core/src/test/resources/log4j-routing3.xml (from r1505096,
logging/log4j/log4j2/trunk/core/src/test/resources/log4j-routing.xml)
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/log4j-routing3.xml?p2=logging/log4j/log4j2/trunk/core/src/test/resources/log4j-routing3.xml&p1=logging/log4j/log4j2/trunk/core/src/test/resources/log4j-routing.xml&r1=1505096&r2=1505102&rev=1505102&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/log4j-routing.xml (original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/log4j-routing3.xml Sat Jul 20 07:21:13
2013
@@ -18,7 +18,7 @@
 -->
 <configuration status="debug" name="RoutingTest" packages="org.apache.logging.log4j.test">
   <properties>
-    <property name="filename">target/routing1/routingtest-$${sd:type}.log</property>
+    <property name="filename">target/routing1/routingtest.log</property>
   </properties>
   <ThresholdFilter level="debug"/>
 
@@ -29,19 +29,18 @@
     <List name="List">
       <ThresholdFilter level="debug"/>
     </List>
+    <RollingFile name="RollingFile" fileName="${filename}"
+                 filePattern="target/routing1/test1-%i.log.gz">
+      <PatternLayout>
+        <pattern>%d %p %C{1.} [%t] %m%n</pattern>
+      </PatternLayout>
+      <SizeBasedTriggeringPolicy size="500" />
+    </RollingFile>
     <Routing name="Routing">
       <Routes pattern="$${sd:type}">
-        <Route>
-          <RollingFile name="Routing-${sd:type}" fileName="${filename}"
-                       filePattern="target/routing1/test1-${sd:type}.%i.log.gz">
-            <PatternLayout>
-              <pattern>%d %p %C{1.} [%t] %m%n</pattern>
-            </PatternLayout>
-            <SizeBasedTriggeringPolicy size="500" />
-          </RollingFile>
-        </Route>
         <Route ref="STDOUT" key="Audit"/>
         <Route ref="List" key="Service"/>
+        <Route ref="RollingFile"/>
       </Routes>
     </Routing>
   </appenders>

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1505102&r1=1505101&r2=1505102&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Sat Jul 20 07:21:13 2013
@@ -21,6 +21,9 @@
   </properties>
   <body>
     <release version="2.0-beta9" date="soon, very soon" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-166" dev="rgoers" type="fix">
+        RoutingAppender's default Route can now be an appender reference.
+      </action>
       <action issue="LOG4J2-313" dev="rgoers" type="add" due-to="Woonsan Ko">
         Add JNDILookup plugin.
       </action>



Mime
View raw message