logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1555442 - 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:25:25 GMT
Author: rgoers
Date: Sun Jan  5 01:25:24 2014
New Revision: 1555442

URL: http://svn.apache.org/r1555442
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=1555442&r1=1555441&r2=1555442&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:25:24 2014
@@ -29,6 +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.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.helpers.Constants;
@@ -53,6 +54,7 @@ public class LoggerTest {
     private static Configuration config;
     private static ListAppender app;
     private static ListAppender host;
+    private static FileAppender hostFile;
     private static ListAppender noThrown;
     private static LoggerContext ctx;
 
@@ -79,10 +81,13 @@ public class LoggerTest {
                 host = (ListAppender) entry.getValue();
             } else if (entry.getKey().equals("NoThrowable")) {
                 noThrown = (ListAppender) entry.getValue();
+            } else if (entry.getKey().equals("HostFile")) {
+                hostFile = (FileAppender) entry.getValue();
             }
         }
         assertNotNull("No Appender", app);
         assertNotNull("No Host Appender", host);
+        assertNotNull("No Host FileAppender", hostFile);
         app.clear();
         host.clear();
     }
@@ -186,9 +191,14 @@ public class LoggerTest {
         testLogger.debug("Hello, {}", "World");
         final List<String> msgs = host.getMessages();
         assertTrue("Incorrect number of events. Expected 1, actual " + msgs.size(), msgs.size()
== 1);
-        final String expected = NetUtils.getLocalHostname() + Constants.LINE_SEP;
+        String expected = NetUtils.getLocalHostname() + Constants.LINE_SEP;
         assertTrue("Incorrect hostname - expected " + expected + " actual - " + msgs.get(0),
             msgs.get(0).endsWith(expected));
+        assertNotNull("No Host FileAppender file name", hostFile.getFileName());
+        expected = "target/" + NetUtils.getLocalHostname() + ".log";
+        String name = hostFile.getFileName();
+        assertTrue("Incorrect HostFile FileAppender file name - 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=1555442&r1=1555441&r2=1555442&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:25:24
2014
@@ -23,6 +23,11 @@
   <ThresholdFilter level="trace"/>
 
   <Appenders>
+    <File name="HostFile" fileName="target/${hostName}.log">
+      <PatternLayout>
+        <Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
+      </PatternLayout>
+    </File>
     <Console name="STDOUT">
       <PatternLayout pattern="%m MDC%X%n"/>
       <filters>



Mime
View raw message