You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/09/11 06:28:05 UTC
[24/50] logging-log4j2 git commit: LOG4J2-1349 (work in progress)
update tests to prove garbage-free context map does not allocate
LOG4J2-1349 (work in progress) update tests to prove garbage-free context map does not allocate
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/1e4f0ffb
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/1e4f0ffb
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/1e4f0ffb
Branch: refs/heads/master
Commit: 1e4f0ffbe9ac4611ea11b0c23f0b2d0918760a3e
Parents: 22ef566
Author: rpopma <rp...@apache.org>
Authored: Thu Sep 1 01:26:54 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Thu Sep 1 01:26:54 2016 +0900
----------------------------------------------------------------------
.../logging/log4j/core/GcFreeAsynchronousLoggingTest.java | 2 ++
.../org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java | 8 ++++++--
.../logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java | 1 +
.../logging/log4j/core/GcFreeSynchronousLoggingTest.java | 1 +
log4j-core/src/test/resources/gcFreeLogging.xml | 2 +-
.../src/test/resources/gcFreeMixedSyncAsyncLogging.xml | 2 +-
6 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1e4f0ffb/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeAsynchronousLoggingTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeAsynchronousLoggingTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeAsynchronousLoggingTest.java
index 0e22b3e..188605a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeAsynchronousLoggingTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeAsynchronousLoggingTest.java
@@ -35,6 +35,8 @@ public class GcFreeAsynchronousLoggingTest {
* This code runs in a separate process, instrumented with the Google Allocation Instrumenter.
*/
public static void main(final String[] args) throws Exception {
+ System.setProperty("log4j2.garbagefree.threadContextMap", "true");
+ System.setProperty("AsyncLogger.RingBufferSize", "128"); // minimum ringbuffer size
System.setProperty("Log4jContextSelector", AsyncLoggerContextSelector.class.getName());
GcFreeLoggingTestUtil.executeLogging("gcFreeLogging.xml", GcFreeAsynchronousLoggingTest.class);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1e4f0ffb/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
index 1394b9f..9cf4164 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeLoggingTestUtil.java
@@ -53,12 +53,16 @@ public class GcFreeLoggingTestUtil {
// initialize LoggerContext etc.
// This is not steady-state logging and will allocate objects.
+
+ ThreadContext.put("aKey", "value1");
+ ThreadContext.put("key2", "value2");
+
final org.apache.logging.log4j.Logger logger = LogManager.getLogger(testClass.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");
- for (int i = 0; i < 128; i++) {
+ for (int i = 0; i < 256; i++) {
logger.debug("ensure all ringbuffer slots have been used once"); // allocate MutableLogEvent.messageText
}
@@ -128,7 +132,7 @@ public class GcFreeLoggingTestUtil {
final String text = new String(Files.readAllBytes(tempFile.toPath()));
final List<String> lines = Files.readAllLines(tempFile.toPath(), Charset.defaultCharset());
final String className = cls.getSimpleName();
- assertEquals(text, "FATAL o.a.l.l.c." + className + " [main] This message is logged to the console",
+ assertEquals(text, "FATAL o.a.l.l.c." + className + " [main] value1 {aKey=value1, key2=value2} This message is logged to the console",
lines.get(0));
final String LINESEP = System.getProperty("line.separator");
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1e4f0ffb/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java
index 8ed4d1b..93ddc2c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java
@@ -34,6 +34,7 @@ public class GcFreeMixedSyncAyncLoggingTest {
* This code runs in a separate process, instrumented with the Google Allocation Instrumenter.
*/
public static void main(final String[] args) throws Exception {
+ System.setProperty("log4j2.garbagefree.threadContextMap", "true");
System.setProperty("AsyncLoggerConfig.RingBufferSize", "128"); // minimum ringbuffer size
GcFreeLoggingTestUtil.executeLogging("gcFreeMixedSyncAsyncLogging.xml", GcFreeMixedSyncAyncLoggingTest.class);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1e4f0ffb/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java
index 2d0ecc6..8ab6e8b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java
@@ -34,6 +34,7 @@ public class GcFreeSynchronousLoggingTest {
* This code runs in a separate process, instrumented with the Google Allocation Instrumenter.
*/
public static void main(final String[] args) throws Exception {
+ System.setProperty("log4j2.garbagefree.threadContextMap", "true");
GcFreeLoggingTestUtil.executeLogging("gcFreeLogging.xml", GcFreeSynchronousLoggingTest.class);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1e4f0ffb/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 d4b597f..81a8055 100644
--- a/log4j-core/src/test/resources/gcFreeLogging.xml
+++ b/log4j-core/src/test/resources/gcFreeLogging.xml
@@ -2,7 +2,7 @@
<Configuration status="OFF">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%p %c{1.} [%t] %X{aKey} %m%ex%n" />
+ <PatternLayout pattern="%p %c{1.} [%t] %X{aKey} %X %m%ex%n" />
</Console>
<File name="File" fileName="target/gcfreefile.log" bufferedIO="false">
<PatternLayout>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1e4f0ffb/log4j-core/src/test/resources/gcFreeMixedSyncAsyncLogging.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/gcFreeMixedSyncAsyncLogging.xml b/log4j-core/src/test/resources/gcFreeMixedSyncAsyncLogging.xml
index f1937be..714ea9f 100644
--- a/log4j-core/src/test/resources/gcFreeMixedSyncAsyncLogging.xml
+++ b/log4j-core/src/test/resources/gcFreeMixedSyncAsyncLogging.xml
@@ -2,7 +2,7 @@
<Configuration status="OFF">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
- <PatternLayout pattern="%p %c{1.} [%t] %X{aKey} %m%ex%n" />
+ <PatternLayout pattern="%p %c{1.} [%t] %X{aKey} %X %m%ex%n" />
</Console>
<File name="File" fileName="target/gcfreefileMixed.log" bufferedIO="false">
<PatternLayout>