You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2016/04/08 14:04:15 UTC

[23/50] logging-log4j2 git commit: LOG4J2-1295 increased scope of garbage-free logging test to include Console, File, RollingFile, RollingRandomAccessFile, MemoryMappedFile (and the previous RandomAccessFile) appenders

LOG4J2-1295	increased scope of garbage-free logging test to include Console, File, RollingFile, RollingRandomAccessFile, MemoryMappedFile (and the previous RandomAccessFile) appenders


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/04a10cfc
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/04a10cfc
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/04a10cfc

Branch: refs/heads/LOG4J2-1356
Commit: 04a10cfcbaee758abac02494f491795253ef39c7
Parents: 306bfca
Author: rpopma <rp...@apache.org>
Authored: Thu Apr 7 03:11:29 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Thu Apr 7 03:11:29 2016 +0900

----------------------------------------------------------------------
 .../logging/log4j/core/GcFreeLoggingTest.java   |  5 ++-
 log4j-core/src/test/resources/gcFreeLogging.xml | 45 +++++++++++++++++++-
 2 files changed, 47 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/04a10cfc/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTest.java
index eed91ec..c151917 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTest.java
@@ -57,7 +57,9 @@ public class GcFreeLoggingTest {
         process.exitValue();
 
         final String output = new String(Files.readAllBytes(tempFile.toPath()));
-        assertEquals("", output);
+        final String NEWLINE = System.getProperty("line.separator");
+        assertEquals("FATAL o.a.l.l.c.GcFreeLoggingTest [main]  This message is logged to the console"
+                + NEWLINE, output);
     }
 
     /**
@@ -76,6 +78,7 @@ public class GcFreeLoggingTest {
         // This is not steady-state logging and will allocate objects.
         final Logger logger = LogManager.getLogger(GcFreeLoggingTest.class.getName());
         logger.debug("debug not set");
+        logger.fatal("This message is logged to the console");
         logger.error("Sample error message");
         logger.error("Test parameterized message {}", "param");
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/04a10cfc/log4j-core/src/test/resources/gcFreeLogging.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/gcFreeLogging.xml b/log4j-core/src/test/resources/gcFreeLogging.xml
index 560c83c..b477bdc 100644
--- a/log4j-core/src/test/resources/gcFreeLogging.xml
+++ b/log4j-core/src/test/resources/gcFreeLogging.xml
@@ -1,11 +1,46 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Configuration status="OFF">
   <Appenders>
-    <RandomAccessFile name="RandomAccessFilePattern" fileName="gcfree.log" immediateFlush="false" append="false">
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%p %c{1.} [%t] %X{aKey} %m%ex%n" />
+    </Console>
+    <File name="File" fileName="target/gcfreefile.log" bufferedIO="false">
+      <PatternLayout>
+        <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+      </PatternLayout>
+    </File>
+    <RollingFile name="RollingFile" fileName="target/gcfreeRollingFile.log"
+        filePattern="target/gcfree-%d{MM-dd-yy-HH-mm-ss}.log.gz">
+      <PatternLayout>
+        <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+      </PatternLayout>
+      <Policies>
+        <SizeBasedTriggeringPolicy size="50M" />
+      </Policies>
+    </RollingFile>
+    <RandomAccessFile name="RandomAccessFile" fileName="target/gcfreeRAF.log" immediateFlush="false" append="false">
       <PatternLayout>
         <Pattern>%d %p %c{1.} [%t] %X{aKey} %m %ex%n</Pattern>
       </PatternLayout>
     </RandomAccessFile>
+    <RollingRandomAccessFile name="RollingRandomAccessFile"
+        fileName="target/gcfreeRRAF.log"
+        filePattern="target/afterRollover-%i.log" append="false"
+        immediateFlush="false">
+      <PatternLayout>
+        <Pattern>%d %p %c{1.} [%t] %X{aKey} %m %location %ex%n</Pattern>
+      </PatternLayout>
+      <Policies>
+        <SizeBasedTriggeringPolicy size="50 M"/>
+      </Policies>
+    </RollingRandomAccessFile>
+    <MemoryMappedFile name="MemoryMappedFile"
+        fileName="target/gcfreemmap.log"
+        immediateFlush="false" append="false">
+      <PatternLayout>
+        <Pattern>%d %p %c{1.} [%t] %X{aKey} %m%ex%n</Pattern>
+      </PatternLayout>
+    </MemoryMappedFile>
 <!--
     <RandomAccessFile name="RandomAccessFileGelf" fileName="gcfree.json" immediateFlush="false" append="false">
       <GelfLayout compressionType="OFF"/>
@@ -14,7 +49,13 @@
   </Appenders>
   <Loggers>
     <Root level="info" includeLocation="false">
-      <appender-ref ref="RandomAccessFilePattern"/>
+      <appender-ref ref="Console" level="FATAL" />
+      <appender-ref ref="File"/>
+      <appender-ref ref="RandomAccessFile"/>
+      <appender-ref ref="RollingRandomAccessFile"/>
+      <appender-ref ref="File"/>
+      <appender-ref ref="RollingFile"/>
+      <appender-ref ref="MemoryMappedFile"/>
       <!-- <appender-ref ref="RandomAccessFileGelf"/> -->
     </Root>
   </Loggers>