logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1555444 - in /logging/log4j/log4j2/trunk/log4j-core/src/test: java/org/apache/logging/log4j/core/LoggerTest.java resources/log4j-test2.xml
Date Sun, 05 Jan 2014 01:35:25 GMT
Author: rgoers
Date: Sun Jan  5 01:35:25 2014
New Revision: 1555444

URL: http://svn.apache.org/r1555444
Log:
Add unit test for LOG4J2-470

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-test2.xml

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java?rev=1555444&r1=1555443&r2=1555444&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
Sun Jan  5 01:35:25 2014
@@ -29,7 +29,7 @@ import java.util.Map;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.MarkerManager;
 import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.appender.FileAppender;
+import org.apache.logging.log4j.core.appender.RollingFileAppender;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.helpers.Constants;
@@ -54,7 +54,7 @@ public class LoggerTest {
     private static Configuration config;
     private static ListAppender app;
     private static ListAppender host;
-    private static FileAppender hostFile;
+    private static RollingFileAppender hostFile;
     private static ListAppender noThrown;
     private static LoggerContext ctx;
 
@@ -82,7 +82,7 @@ public class LoggerTest {
             } else if (entry.getKey().equals("NoThrowable")) {
                 noThrown = (ListAppender) entry.getValue();
             } else if (entry.getKey().equals("HostFile")) {
-                hostFile = (FileAppender) entry.getValue();
+                hostFile = (RollingFileAppender) entry.getValue();
             }
         }
         assertNotNull("No Appender", app);
@@ -199,6 +199,11 @@ public class LoggerTest {
         String name = hostFile.getFileName();
         assertTrue("Incorrect HostFile FileAppender file name - expected " + expected + "
actual - " + name,
             name.equals(expected));
+        name = hostFile.getFilePattern();
+        assertNotNull("No file pattern", name);
+        expected = "target/" + NetUtils.getLocalHostname() + "-%d{MM-dd-yyyy}-%i.log";
+        assertTrue("Incorrect HostFile FileAppender file pattern - expected " + expected
+ " actual - " + name,
+            name.equals(expected));
 
     }
 

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-test2.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-test2.xml?rev=1555444&r1=1555443&r2=1555444&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-test2.xml (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/resources/log4j-test2.xml Sun Jan  5 01:35:25
2014
@@ -23,11 +23,15 @@
   <ThresholdFilter level="trace"/>
 
   <Appenders>
-    <File name="HostFile" fileName="target/${hostName}.log">
+    <RollingFile name="HostFile" fileName="target/${hostName}.log" filePattern="target/${hostName}-%d{MM-dd-yyyy}-%i.log">
       <PatternLayout>
         <Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
       </PatternLayout>
-    </File>
+      <Policies>
+        <OnStartupTriggeringPolicy />
+        <TimeBasedTriggeringPolicy interval="24" modulate="true" />
+      </Policies>
+    </RollingFile>
     <Console name="STDOUT">
       <PatternLayout pattern="%m MDC%X%n"/>
       <filters>



Mime
View raw message