logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1334559 - in /logging/log4j/log4j2/trunk/core/src/test: java/org/apache/logging/log4j/core/ThreadedTest.java resources/log4j-threaded.xml
Date Sun, 06 May 2012 05:41:23 GMT
Author: rgoers
Date: Sun May  6 05:41:23 2012
New Revision: 1334559

URL: http://svn.apache.org/viewvc?rev=1334559&view=rev
Log:
write output to a file

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

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/ThreadedTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/ThreadedTest.java?rev=1334559&r1=1334558&r2=1334559&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/ThreadedTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/ThreadedTest.java
Sun May  6 05:41:23 2012
@@ -26,6 +26,7 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import java.io.File;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -33,6 +34,7 @@ import java.util.concurrent.Executors;
  *
  */
 public class ThreadedTest {
+    private static final String DIR = "target/threaded";
     private static final String CONFIG = "log4j-threaded.xml";
     private Logger logger = LogManager.getLogger(ThreadedTest.class.getName());
     private volatile Level lvl = Level.DEBUG;
@@ -42,6 +44,7 @@ public class ThreadedTest {
 
     @BeforeClass
     public static void setupClass() {
+        deleteDir();
         System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
         LoggerContext ctx = (LoggerContext) LogManager.getContext();
         Configuration config = ctx.getConfiguration();
@@ -49,6 +52,7 @@ public class ThreadedTest {
 
     @AfterClass
     public static void cleanupClass() {
+        deleteDir();
         System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
         LoggerContext ctx = (LoggerContext) LogManager.getContext();
         ctx.reconfigure();
@@ -94,6 +98,17 @@ public class ThreadedTest {
         }
     }
 
+    private static void deleteDir() {
+        File dir = new File(DIR);
+        if (dir.exists()) {
+            File[] files = dir.listFiles();
+            for (File file : files) {
+                file.delete();
+            }
+            dir.delete();
+        }
+    }
+
     class State {
 
         synchronized void setState() {

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/log4j-threaded.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/log4j-threaded.xml?rev=1334559&r1=1334558&r2=1334559&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/log4j-threaded.xml (original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/log4j-threaded.xml Sun May  6 05:41:23
2012
@@ -19,6 +19,11 @@
 <configuration status="warn" name="XMLConfigTest" packages="org.apache.logging.log4j.test">
 
   <appenders>
+    <File name="File" fileName="target/threaded/test.log" bufferedIO="false">
+      <PatternLayout>
+        <pattern>%d %p %C{1.} [%t] %m%n</pattern>
+      </PatternLayout>
+    </File>
     <Console name="STDOUT">
       <PatternLayout pattern="%d %p %C{1.} [%t] %m%n"/>
     </Console>
@@ -31,7 +36,7 @@
 
   <loggers>
     <root level="debug">
-      <appender-ref ref="STDOUT"/>
+      <appender-ref ref="File"/>
     </root>
   </loggers>
 



Mime
View raw message