You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2016/04/26 06:30:57 UTC
[01/34] logging-log4j2 git commit: cleanup
Repository: logging-log4j2
Updated Branches:
refs/heads/LOG4j2-494 f7909e240 -> bf3ef615b
cleanup
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/d8161086
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d8161086
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d8161086
Branch: refs/heads/LOG4j2-494
Commit: d8161086890d99226593408172530583a9e00497
Parents: 02cb0fd
Author: rpopma <rp...@apache.org>
Authored: Thu Apr 21 14:34:23 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:27 2016 -0700
----------------------------------------------------------------------
.../core/async/perftest/SimpleLatencyTest.java | 30 +-------------------
1 file changed, 1 insertion(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d8161086/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
index cad4e55..8665d5d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
@@ -31,33 +31,6 @@ import org.apache.logging.log4j.core.async.EventRoute;
/**
* Latency test.
- * <p>
- * See <a href="https://groups.google.com/d/msg/mechanical-sympathy/0gaBXxFm4hE/O9QomwHIJAAJ">https://groups.google.com/d/msg/mechanical-sympathy/0gaBXxFm4hE/O9QomwHIJAAJ</a>:
- * </p>
- * <p>Gil Tene's rules of thumb for latency tests:</p>
- * <ol>
- * <li>DO measure max achievable throughput, but DON'T get focused on it as the main or single axis of measurement /
- * comparison.</li>
- * <li>DO measure response time / latency behaviors across a spectrum of attempted load levels (e.g. at attempted loads
- * between 2% to 100%+ of max established thoughout).</li>
- * <li>DO measure the response time / latency spectrum for each tested load (even for max throughout, for which response
- * time should linearly grow with test length, or the test is wrong). HdrHistogram is one good way to capture this
- * information.</li>
- * <li>DO make sure you are measuring response time correctly and labeling it right. If you also measure and report
- * service time, label it as such (don't call it "latency").
- * <li>DO compare response time / latency spectrum at given loads.</li>
- * <li>DO [repeatedly] sanity check and calibrate the benchmark setup to verify that it produces expected results for
- * known forced scenarios. E.g. forced pauses of known size via ^Z or SIGSTOP/SIGCONT should produce expected response
- * time percentile levels. Attempting to load at >100% than achieved throughput should result in response time / latency
- * measurements that grow with benchmark run length, while service time (if measured) should remain fairly flat well
- * past saturation.</li>
- * <li>DON'T use or report standard deviation for latency. Ever. Except if you mean it as a joke.</li>
- * <li>DON'T use average latency as a way to compare things with one another. [use median or 90%'ile instead, if what
- * you want to compare is "common case" latencies]. Consider not reporting avg. at all.</li>
- * <li>DON'T compare results of different setups or loads from short runs (< 20-30 minutes).</li>
- * <li>DON'T include process warmup behavior (e.g. 1st minute and 1st 50K messages) in compared or reported results.
- * </li>
- * </ol>
*/
// -DAsyncLogger.WaitStrategy=busywait
//-XX:+UnlockDiagnosticVMOptions -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime
@@ -69,7 +42,6 @@ public class SimpleLatencyTest {
System.out.println("Please specify thread count and interval (us)");
return;
}
-// double targetLoadLevel = Double.parseDouble(args[0]);
final int threadCount = Integer.parseInt(args[0]);
final int intervalMicros = Integer.parseInt(args[1]);
@@ -101,7 +73,7 @@ public class SimpleLatencyTest {
List<Histogram> histograms = new ArrayList<>(threadCount);
final long TEST_DURATION_MILLIS = TimeUnit.MINUTES.toMillis(4);
- final int COUNT = 5000000 / threadCount;
+ final int COUNT = (5000 * 1000) / threadCount;
runLatencyTest(logger, TEST_DURATION_MILLIS, COUNT, interval, idleStrategy, histograms, nanoTimeCost, threadCount);
long end = System.currentTimeMillis();
[25/34] logging-log4j2 git commit: Useful toString().
Posted by rg...@apache.org.
Useful toString().
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/bb534792
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/bb534792
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/bb534792
Branch: refs/heads/LOG4j2-494
Commit: bb534792de01003c8344a39e9f6f07b1517980bf
Parents: 67070d3
Author: ggregory <gg...@apache.org>
Authored: Thu Apr 21 23:09:15 2016 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:30 2016 -0700
----------------------------------------------------------------------
.../java/org/apache/logging/log4j/junit/CleanFiles.java | 9 +++++++++
1 file changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/bb534792/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
index 6c0ac76..00615b8 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
@@ -67,4 +67,13 @@ public class CleanFiles extends ExternalResource {
protected void after() {
this.clean();
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("CleanFiles [");
+ builder.append(files);
+ builder.append("]");
+ return builder.toString();
+ }
}
[14/34] logging-log4j2 git commit: LOG4J2-1342 use new method
ReusableMessage#memento() to take snapshot without losing parameter
information
Posted by rg...@apache.org.
LOG4J2-1342 use new method ReusableMessage#memento() to take snapshot without losing parameter information
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/04ee75ff
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/04ee75ff
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/04ee75ff
Branch: refs/heads/LOG4j2-494
Commit: 04ee75ff52276f02caa248a33bc8c0da7ded10ef
Parents: c172995
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:39:34 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:29 2016 -0700
----------------------------------------------------------------------
.../java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/04ee75ff/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
index 26b35d3..776fba7 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java
@@ -844,7 +844,7 @@ public Log4jLogEvent(final String loggerName, final Marker marker, final String
}
private Message memento(final ReusableMessage message) {
- return new SimpleMessage(message.getFormattedMessage());
+ return message.memento();
}
/**
[06/34] logging-log4j2 git commit: LOG4J2-1342 use more reliable
CountDownLatch to ensure background thread is finished
Posted by rg...@apache.org.
LOG4J2-1342 use more reliable CountDownLatch to ensure background thread is finished
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b2e90dc4
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b2e90dc4
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b2e90dc4
Branch: refs/heads/LOG4j2-494
Commit: b2e90dc40cfa7789b960f76fc853c1ab79fe8422
Parents: 047202a
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:24:00 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:28 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/core/layout/CsvParameterLayoutTest.java | 9 +++++----
.../apache/logging/log4j/test/appender/ListAppender.java | 6 ++++++
2 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b2e90dc4/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
index ce3abfc..a51db99 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
@@ -21,6 +21,8 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import org.apache.commons.csv.CSVFormat;
import org.apache.logging.log4j.Level;
@@ -97,6 +99,8 @@ public class CsvParameterLayoutTest {
final ListAppender appender = new ListAppender("List", null, layout, true, false);
appender.start();
+ appender.countDownLatch = new CountDownLatch(4);
+
// set appender on root and set level to debug
root.addAppender(appender);
root.setLevel(Level.DEBUG);
@@ -109,10 +113,7 @@ public class CsvParameterLayoutTest {
}
// wait until background thread finished processing
- int maxTries = 50;
- while (appender.getMessages().size() < 4 && maxTries-- > 0) {
- Thread.sleep(1L);
- }
+ appender.countDownLatch.await(10, TimeUnit.SECONDS);
assertEquals("Background thread did not finish processing: msg count", 4, appender.getMessages().size());
// don't stop appender until background thread is done
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b2e90dc4/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java b/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
index 19aeaee..acab7c1 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/ListAppender.java
@@ -20,6 +20,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Layout;
@@ -60,6 +61,8 @@ public class ListAppender extends AbstractAppender {
private static final String WINDOWS_LINE_SEP = "\r\n";
+ public CountDownLatch countDownLatch = null;
+
public ListAppender(final String name) {
super(name, null, null);
newLine = false;
@@ -99,6 +102,9 @@ public class ListAppender extends AbstractAppender {
} else {
write(layout.toByteArray(event));
}
+ if (countDownLatch != null) {
+ countDownLatch.countDown();
+ }
}
void write(final byte[] bytes) {
[10/34] logging-log4j2 git commit: LOG4J2-1342 added methods to
ReusableMessage to enable passing parameters to async logger background
threads
Posted by rg...@apache.org.
LOG4J2-1342 added methods to ReusableMessage to enable passing parameters to async logger background threads
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/79e51b23
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/79e51b23
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/79e51b23
Branch: refs/heads/LOG4j2-494
Commit: 79e51b23e1b74b9233c603067fd1da2f0a721130
Parents: 873e19b
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 12:10:34 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:28 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/message/ReusableMessage.java | 31 +++++++
.../log4j/message/ReusableObjectMessage.java | 19 ++++
.../message/ReusableParameterizedMessage.java | 20 ++++
.../log4j/message/ReusableSimpleMessage.java | 18 ++++
.../core/async/AsyncLoggerConfigDisruptor.java | 2 +-
.../log4j/core/async/RingBufferLogEvent.java | 98 +++++++++++++-------
.../log4j/core/impl/MutableLogEvent.java | 67 ++++++++++---
7 files changed, 209 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/79e51b23/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
index a6da9c4..0536b23 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
@@ -30,4 +30,35 @@ import org.apache.logging.log4j.util.StringBuilderFormattable;
*/
@PerformanceSensitive("allocation")
public interface ReusableMessage extends Message, StringBuilderFormattable {
+
+ /**
+ * Returns the parameter array that was used to initialize this reusable message and replaces it with the specified
+ * array. The returned parameter array will no longer be modified by this reusable message. The specified array is
+ * now "owned" by this reusable message and can be modified if necessary for the next log event.
+ * </p><p>
+ * ReusableMessages that have no parameters return the specified array.
+ * </p><p>
+ * This method is used by asynchronous loggers to pass the parameter array to a background thread without
+ * allocating new objects.
+ * The actual number of parameters in the returned array can be determined with {@link #getParameterCount()}.
+ * </p>
+ *
+ * @param emptyReplacement the parameter array that can be used for subsequent uses of this reusable message.
+ * This replacement array must have at least 10 elements (the number of varargs supported by the Logger
+ * API).
+ * @return the parameter array for the current message content. This may be a vararg array of any length, or it may
+ * be a reusable array of 10 elements used to hold the unrolled vararg parameters.
+ * @see #getParameterCount()
+ */
+ Object[] swapParameters(Object[] emptyReplacement);
+
+ /**
+ * Returns the number of parameters that was used to initialize this reusable message for the current content.
+ * <p>
+ * The parameter array returned by {@link #swapParameters(Object[])} may be larger than the actual number of
+ * parameters. Callers should use this method to determine how many elements the array contains.
+ * </p>
+ * @return the current number of parameters
+ */
+ short getParameterCount();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/79e51b23/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
index 12f62f4..920eff4 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
@@ -91,4 +91,23 @@ public class ReusableObjectMessage implements ReusableMessage {
public Throwable getThrowable() {
return obj instanceof Throwable ? (Throwable) obj : null;
}
+
+ /**
+ * This message does not have any parameters, so this method returns the specified array.
+ * @param emptyReplacement the parameter array to return
+ * @return the specified array
+ */
+ @Override
+ public Object[] swapParameters(final Object[] emptyReplacement) {
+ return emptyReplacement;
+ }
+
+ /**
+ * This message does not have any parameters so this method always returns zero.
+ * @return 0 (zero)
+ */
+ @Override
+ public short getParameterCount() {
+ return 0;
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/79e51b23/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
index 87cdc1d..4913c64 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
@@ -55,6 +55,26 @@ public class ReusableParameterizedMessage implements ReusableMessage {
return varargs == null ? params : varargs;
}
+ // see interface javadoc
+ @Override
+ public Object[] swapParameters(final Object[] emptyReplacement) {
+ Object[] result;
+ if (varargs == null) {
+ result = params;
+ params = emptyReplacement;
+ } else {
+ result = varargs;
+ varargs = emptyReplacement;
+ }
+ return result;
+ }
+
+ // see interface javadoc
+ @Override
+ public short getParameterCount() {
+ return (short) argCount;
+ }
+
private void init(final String messagePattern, final int argCount, final Object[] paramArray) {
this.varargs = null;
this.messagePattern = messagePattern;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/79e51b23/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
index ed6e39e..9fae16c 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
@@ -61,6 +61,24 @@ public class ReusableSimpleMessage implements ReusableMessage, CharSequence {
buffer.append(charSequence);
}
+ /**
+ * This message does not have any parameters, so this method returns the specified array.
+ * @param emptyReplacement the parameter array to return
+ * @return the specified array
+ */
+ @Override
+ public Object[] swapParameters(final Object[] emptyReplacement) {
+ return emptyReplacement;
+ }
+
+ /**
+ * This message does not have any parameters so this method always returns zero.
+ * @return 0 (zero)
+ */
+ @Override
+ public short getParameterCount() {
+ return 0;
+ }
// CharSequence impl
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/79e51b23/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
index 2c1b84f..503e7d8 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
@@ -145,7 +145,7 @@ public class AsyncLoggerConfigDisruptor implements AsyncLoggerConfigDelegate {
private static final EventFactory<Log4jEventWrapper> MUTABLE_FACTORY = new EventFactory<Log4jEventWrapper>() {
@Override
public Log4jEventWrapper newInstance() {
- return new Log4jEventWrapper(new MutableLogEvent());
+ return new Log4jEventWrapper(new MutableLogEvent(new Object[10]));
}
};
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/79e51b23/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
index e1e6ab0..72ae8ac 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
@@ -16,7 +16,11 @@
*/
package org.apache.logging.log4j.core.async;
-import com.lmax.disruptor.EventFactory;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.ThreadContext.ContextStack;
@@ -32,9 +36,7 @@ import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.message.TimestampMessage;
import org.apache.logging.log4j.util.Strings;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
+import com.lmax.disruptor.EventFactory;
/**
* When the Disruptor is started, the RingBuffer is populated with event objects. These objects are then re-used during
@@ -46,7 +48,6 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
public static final Factory FACTORY = new Factory();
private static final long serialVersionUID = 8462119088943934758L;
- private static final Object[] PARAMS = new Object[0];
private static final Message EMPTY = new SimpleMessage(Strings.EMPTY);
/**
@@ -59,56 +60,63 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
RingBufferLogEvent result = new RingBufferLogEvent();
if (Constants.ENABLE_THREADLOCALS) {
result.messageText = new StringBuilder(Constants.INITIAL_REUSABLE_MESSAGE_SIZE);
+ result.parameters = new Object[10];
}
return result;
}
}
- private transient AsyncLogger asyncLogger;
- private String loggerName;
- private Marker marker;
- private String fqcn;
+ private int threadPriority;
+ private long threadId;
+ private long currentTimeMillis;
+ private long nanoTime;
+ private short parameterCount;
+ private boolean includeLocation;
+ private boolean endOfBatch = false;
private Level level;
- private StringBuilder messageText;
+ private String threadName;
+ private String loggerName;
private Message message;
+ private StringBuilder messageText;
+ private Object[] parameters;
private transient Throwable thrown;
private ThrowableProxy thrownProxy;
private Map<String, String> contextMap;
- private ContextStack contextStack;
- private long threadId;
- private String threadName;
- private int threadPriority;
+ private Marker marker;
+ private String fqcn;
private StackTraceElement location;
- private long currentTimeMillis;
- private boolean endOfBatch;
- private boolean includeLocation;
- private long nanoTime;
+ private ContextStack contextStack;
+
+ private transient AsyncLogger asyncLogger;
public void setValues(final AsyncLogger anAsyncLogger, final String aLoggerName, final Marker aMarker,
final String theFqcn, final Level aLevel, final Message msg, final Throwable aThrowable,
final Map<String, String> aMap, final ContextStack aContextStack, long threadId,
final String threadName, int threadPriority, final StackTraceElement aLocation, final long aCurrentTimeMillis, final long aNanoTime) {
- this.asyncLogger = anAsyncLogger;
- this.loggerName = aLoggerName;
- this.marker = aMarker;
- this.fqcn = theFqcn;
+ this.threadPriority = threadPriority;
+ this.threadId = threadId;
+ this.currentTimeMillis = aCurrentTimeMillis;
+ this.nanoTime = aNanoTime;
this.level = aLevel;
+ this.threadName = threadName;
+ this.loggerName = aLoggerName;
+ setMessage(msg);
this.thrown = aThrowable;
this.thrownProxy = null;
this.contextMap = aMap;
- this.contextStack = aContextStack;
- this.threadId = threadId;
- this.threadName = threadName;
- this.threadPriority = threadPriority;
+ this.marker = aMarker;
+ this.fqcn = theFqcn;
this.location = aLocation;
- this.currentTimeMillis = aCurrentTimeMillis;
- this.nanoTime = aNanoTime;
- setMessage(msg);
+ this.contextStack = aContextStack;
+ this.asyncLogger = anAsyncLogger;
}
private void setMessage(final Message msg) {
if (msg instanceof ReusableMessage) {
- ((ReusableMessage) msg).formatTo(getMessageTextForWriting());
+ ReusableMessage reusable = (ReusableMessage) msg;
+ reusable.formatTo(getMessageTextForWriting());
+ parameters = reusable.swapParameters(parameters);
+ parameterCount = reusable.getParameterCount();
} else {
// if the Message instance is reused, there is no point in freezing its message here
if (!Constants.FORMAT_MESSAGES_IN_BACKGROUND && msg != null) { // LOG4J2-898: user may choose
@@ -215,7 +223,7 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
*/
@Override
public Object[] getParameters() {
- return PARAMS;
+ return parameters == null ? null : Arrays.copyOf(parameters, parameterCount);
}
/**
@@ -234,6 +242,27 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
buffer.append(messageText);
}
+ /**
+ * Replaces this ReusableMessage's parameter array with the specified value and return the original array
+ * @param emptyReplacement the parameter array that can be used for subsequent uses of this reusable message
+ * @return the original parameter array
+ * @see ReusableMessage#swapParameters(Object[])
+ */
+ @Override
+ public Object[] swapParameters(final Object[] emptyReplacement) {
+ final Object[] result = this.parameters;
+ this.parameters = emptyReplacement;
+ return result;
+ }
+
+ /*
+ * @see ReusableMessage#getParameterCount
+ */
+ @Override
+ public short getParameterCount() {
+ return parameterCount;
+ }
+
// CharSequence impl
@@ -362,7 +391,14 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
this.contextMap = null;
this.contextStack = null;
this.location = null;
+
trimMessageText();
+
+ if (parameters != null) {
+ for (int i = 0; i < parameters.length; i++) {
+ parameters[i] = null;
+ }
+ }
}
// ensure that excessively long char[] arrays are not kept in memory forever
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/79e51b23/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
index b619615..0393b0c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
@@ -18,6 +18,7 @@ package org.apache.logging.log4j.core.impl;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
+import java.util.Arrays;
import java.util.Map;
import org.apache.logging.log4j.Level;
@@ -35,27 +36,36 @@ import org.apache.logging.log4j.util.Strings;
* @since 2.6
*/
public class MutableLogEvent implements LogEvent, ReusableMessage {
- private static final Object[] PARAMS = new Object[0];
private static final Message EMPTY = new SimpleMessage(Strings.EMPTY);
- private String loggerFqcn;
- private Marker marker;
+ private int threadPriority;
+ private long threadId;
+ private long timeMillis;
+ private long nanoTime;
+ private short parameterCount;
+ private boolean includeLocation;
+ private boolean endOfBatch = false;
private Level level;
+ private String threadName;
private String loggerName;
private Message message;
- private long timeMillis;
+ private StringBuilder messageText;
+ private Object[] parameters;
private Throwable thrown;
private ThrowableProxy thrownProxy;
private Map<String, String> contextMap;
- private ThreadContext.ContextStack contextStack;
- private long threadId;
- private String threadName;
- private int threadPriority;
+ private Marker marker;
+ private String loggerFqcn;
private StackTraceElement source;
- private boolean includeLocation;
- private boolean endOfBatch = false;
- private long nanoTime;
- private StringBuilder messageText;
+ private ThreadContext.ContextStack contextStack;
+
+ public MutableLogEvent() {
+ this(null);
+ }
+
+ public MutableLogEvent(final Object[] replacementParameters) {
+ this.parameters = replacementParameters;
+ }
/**
* Initialize the fields of this {@code MutableLogEvent} from another event.
@@ -107,6 +117,11 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
// threadName = null; // no need to clear threadName
trimMessageText();
+ if (parameters != null) {
+ for (int i = 0; i < parameters.length; i++) {
+ parameters[i] = null;
+ }
+ }
// primitive fields that cannot be cleared:
//timeMillis;
@@ -171,7 +186,10 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
public void setMessage(final Message msg) {
if (msg instanceof ReusableMessage) {
- ((ReusableMessage) msg).formatTo(getMessageTextForWriting()); // init messageText
+ ReusableMessage reusable = (ReusableMessage) msg;
+ reusable.formatTo(getMessageTextForWriting());
+ parameters = reusable.swapParameters(parameters);
+ parameterCount = reusable.getParameterCount();
} else {
// if the Message instance is reused, there is no point in freezing its message here
if (!Constants.FORMAT_MESSAGES_IN_BACKGROUND && msg != null) { // LOG4J2-898: user may choose
@@ -212,7 +230,7 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
*/
@Override
public Object[] getParameters() {
- return PARAMS;
+ return parameters == null ? null : Arrays.copyOf(parameters, parameterCount);
}
/**
@@ -231,6 +249,27 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
buffer.append(messageText);
}
+ /**
+ * Replaces this ReusableMessage's parameter array with the specified value and return the original array
+ * @param emptyReplacement the parameter array that can be used for subsequent uses of this reusable message
+ * @return the original parameter array
+ * @see ReusableMessage#swapParameters(Object[])
+ */
+ @Override
+ public Object[] swapParameters(final Object[] emptyReplacement) {
+ final Object[] result = this.parameters;
+ this.parameters = emptyReplacement;
+ return result;
+ }
+
+ /*
+ * @see ReusableMessage#getParameterCount
+ */
+ @Override
+ public short getParameterCount() {
+ return parameterCount;
+ }
+
@Override
public Throwable getThrown() {
return thrown;
[02/34] logging-log4j2 git commit: cleanup
Posted by rg...@apache.org.
cleanup
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/02cb0fd9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/02cb0fd9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/02cb0fd9
Branch: refs/heads/LOG4j2-494
Commit: 02cb0fd9ef474a5a23add027dc916d6da5c51296
Parents: 9159e84
Author: rpopma <rp...@apache.org>
Authored: Thu Apr 21 14:23:18 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:27 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/core/async/perftest/SimpleLatencyTest.java | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/02cb0fd9/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
index 73e7138..cad4e55 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
@@ -85,13 +85,6 @@ public class SimpleLatencyTest {
final long nanoTimeCost = PerfTest.calcNanoTimeCost();
System.out.println("nanoTimeCost=" + nanoTimeCost);
-// long maxOpsPerSec = 1000 * 1000; // just assume... TODO make parameter
-//
-// long oneOpDurationNanos = TimeUnit.SECONDS.toNanos(1) / maxOpsPerSec;
-// long idleTimeNanos = (long) ((1.0 - targetLoadLevel) * oneOpDurationNanos);
-// idleTimeNanos *= 10;
-// System.out.printf("Idle time is %d nanos at %,f load level%n", idleTimeNanos, targetLoadLevel);
-
final long interval = TimeUnit.MICROSECONDS.toNanos(intervalMicros);// * threadCount;
System.out.printf("%d threads, interval is %d nanos%n", threadCount, interval);
@@ -101,6 +94,7 @@ public class SimpleLatencyTest {
final int WARMUP_COUNT = 50000 / threadCount;
final IdleStrategy idleStrategy = new YieldIdleStrategy();
runLatencyTest(logger, WARMUP_DURATION_MILLIS, WARMUP_COUNT, interval, idleStrategy, warmupHistograms, nanoTimeCost, threadCount);
+ System.out.println("Warmup done.");
Thread.sleep(1000);
long start = System.currentTimeMillis();
[12/34] logging-log4j2 git commit: Fixing missing space typo.
Posted by rg...@apache.org.
Fixing missing space typo.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/6ef68fad
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/6ef68fad
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/6ef68fad
Branch: refs/heads/LOG4j2-494
Commit: 6ef68fad21b378ffb7a118f4df6f23aa09941741
Parents: 0ad2b6d
Author: ggregory <gg...@apache.org>
Authored: Thu Apr 21 11:00:24 2016 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:28 2016 -0700
----------------------------------------------------------------------
src/site/xdoc/manual/layouts.xml.vm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6ef68fad/src/site/xdoc/manual/layouts.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/layouts.xml.vm b/src/site/xdoc/manual/layouts.xml.vm
index 714accd..83f2e57 100644
--- a/src/site/xdoc/manual/layouts.xml.vm
+++ b/src/site/xdoc/manual/layouts.xml.vm
@@ -541,7 +541,7 @@ WARN [main]: Message 2</pre>
</td>
<td>
<p>Outputs the fully qualified class name of the caller issuing the logging request.
- This conversion specifier can be optionally followed by<em>precision specifier</em>, that
+ This conversion specifier can be optionally followed by <em>precision specifier</em>, that
follows the same rules as the logger name converter.
</p>
<p>Generating the class name of the caller (<a href="#LocationInformation">location information</a>)
[13/34] logging-log4j2 git commit: LOG4J2-1342 ensure internal array
is not set to null by incorrect swap() invocation
Posted by rg...@apache.org.
LOG4J2-1342 ensure internal array is not set to null by incorrect swap() invocation
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/047202aa
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/047202aa
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/047202aa
Branch: refs/heads/LOG4j2-494
Commit: 047202aa1fc3681f1f546eebd08f2a94b426a993
Parents: fb5e730
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 12:51:13 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:28 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/message/ReusableParameterizedMessage.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/047202aa/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
index 4913c64..12f4346 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
@@ -17,6 +17,7 @@
package org.apache.logging.log4j.message;
import java.util.Arrays;
+import java.util.Objects;
import org.apache.logging.log4j.util.PerformanceSensitive;
@@ -61,10 +62,10 @@ public class ReusableParameterizedMessage implements ReusableMessage {
Object[] result;
if (varargs == null) {
result = params;
- params = emptyReplacement;
+ params = Objects.requireNonNull(emptyReplacement);
} else {
result = varargs;
- varargs = emptyReplacement;
+ varargs = Objects.requireNonNull(emptyReplacement);
}
return result;
}
[08/34] logging-log4j2 git commit: Fixing missing space typo.
Posted by rg...@apache.org.
Fixing missing space typo.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0ad2b6d0
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0ad2b6d0
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0ad2b6d0
Branch: refs/heads/LOG4j2-494
Commit: 0ad2b6d0f95b18674628949365c6ee8931c0cf9a
Parents: 8dd1868
Author: ggregory <gg...@apache.org>
Authored: Thu Apr 21 11:00:08 2016 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:28 2016 -0700
----------------------------------------------------------------------
src/site/xdoc/manual/layouts.xml.vm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0ad2b6d0/src/site/xdoc/manual/layouts.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/layouts.xml.vm b/src/site/xdoc/manual/layouts.xml.vm
index ae4c1a0..714accd 100644
--- a/src/site/xdoc/manual/layouts.xml.vm
+++ b/src/site/xdoc/manual/layouts.xml.vm
@@ -490,7 +490,7 @@ WARN [main]: Message 2</pre>
</td>
<td>
<p>Outputs the name of the logger that published the logging event. The logger conversion
- specifier can be optionally followed by<em>precision specifier</em>, which consists of a
+ specifier can be optionally followed by <em>precision specifier</em>, which consists of a
decimal integer, or a pattern starting with a decimal integer.
</p>
<p>If a precision specifier is given and it is an integer value, then only the corresponding number
[09/34] logging-log4j2 git commit: added comments
Posted by rg...@apache.org.
added comments
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8dd1868a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8dd1868a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8dd1868a
Branch: refs/heads/LOG4j2-494
Commit: 8dd1868ac9b941b8681059f47d279712e38790e8
Parents: d816108
Author: rpopma <rp...@apache.org>
Authored: Thu Apr 21 14:42:30 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:28 2016 -0700
----------------------------------------------------------------------
.../core/async/perftest/SimpleLatencyTest.java | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8dd1868a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
index 8665d5d..ff2de75 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimpleLatencyTest.java
@@ -45,6 +45,7 @@ public class SimpleLatencyTest {
final int threadCount = Integer.parseInt(args[0]);
final int intervalMicros = Integer.parseInt(args[1]);
+ // print to console if ringbuffer is full
System.setProperty("log4j2.AsyncEventRouter", PrintingDefaultAsyncEventRouter.class.getName());
System.setProperty("AsyncLogger.RingBufferSize", String.valueOf(256 * 1024));
System.setProperty("Log4jContextSelector", AsyncLoggerContextSelector.class.getName());
@@ -60,6 +61,7 @@ public class SimpleLatencyTest {
final long interval = TimeUnit.MICROSECONDS.toNanos(intervalMicros);// * threadCount;
System.out.printf("%d threads, interval is %d nanos%n", threadCount, interval);
+ // Warmup: run as many iterations of 50,000 calls to logger.log as we can in 1 minute
final long WARMUP_DURATION_MILLIS = TimeUnit.MINUTES.toMillis(1);
List<Histogram> warmupHistograms = new ArrayList<>(threadCount);
@@ -69,6 +71,7 @@ public class SimpleLatencyTest {
System.out.println("Warmup done.");
Thread.sleep(1000);
+ // Actual test: run as many iterations of 5,000,000 calls to logger.log as we can in 4 minutes.
long start = System.currentTimeMillis();
List<Histogram> histograms = new ArrayList<>(threadCount);
@@ -77,6 +80,7 @@ public class SimpleLatencyTest {
runLatencyTest(logger, TEST_DURATION_MILLIS, COUNT, interval, idleStrategy, histograms, nanoTimeCost, threadCount);
long end = System.currentTimeMillis();
+ // ... and report the results
final Histogram result = new Histogram(TimeUnit.SECONDS.toNanos(10), 3);
for (Histogram hist : histograms) {
result.add(hist);
@@ -86,9 +90,8 @@ public class SimpleLatencyTest {
}
public static void runLatencyTest(final Logger logger, final long durationMillis, final int samples,
- final long intervalNanos,
- final IdleStrategy idleStrategy, final List<Histogram> histograms, final long nanoTimeCost,
- final int threadCount) throws InterruptedException {
+ final long intervalNanos, final IdleStrategy idleStrategy, final List<Histogram> histograms,
+ final long nanoTimeCost, final int threadCount) throws InterruptedException {
Thread[] threads = new Thread[threadCount];
final CountDownLatch LATCH = new CountDownLatch(threadCount);
@@ -100,9 +103,9 @@ public class SimpleLatencyTest {
public void run() {
LATCH.countDown();
try {
- LATCH.await();
+ LATCH.await(); // wait until all threads are ready to go
} catch (InterruptedException e) {
- interrupt(); // restore interrupt status
+ interrupt();
return;
}
long start = System.currentTimeMillis();
@@ -118,7 +121,9 @@ public class SimpleLatencyTest {
}
}
- private static void runLatencyTest(int samples, Logger logger, long nanoTimeCost, Histogram hist, long intervalNanos, IdleStrategy idleStrategy) {
+ private static void runLatencyTest(int samples, Logger logger, long nanoTimeCost, Histogram hist,
+ long intervalNanos, IdleStrategy idleStrategy) {
+
for (int i = 0; i < samples; i++) {
final long s1 = System.nanoTime();
logger.info(LATENCY_MSG);
[27/34] logging-log4j2 git commit: Useful toString(),
especially when you use the Eclipse JUnit view.
Posted by rg...@apache.org.
Useful toString(), especially when you use the Eclipse JUnit view.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/67070d39
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/67070d39
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/67070d39
Branch: refs/heads/LOG4j2-494
Commit: 67070d393bd6ea427a6d7748622b7737ab529a9a
Parents: bc81c74
Author: ggregory <gg...@apache.org>
Authored: Thu Apr 21 23:08:36 2016 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:30 2016 -0700
----------------------------------------------------------------------
.../apache/logging/log4j/junit/LoggerContextRule.java | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/67070d39/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
index 5bbda4f..59e921d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java
@@ -204,4 +204,15 @@ public class LoggerContextRule implements TestRule {
}
throw new AssertionError("No ListAppender named " + name + " found.");
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("LoggerContextRule [configLocation=");
+ builder.append(configLocation);
+ builder.append(", contextSelectorClass=");
+ builder.append(contextSelectorClass);
+ builder.append("]");
+ return builder.toString();
+ }
}
[28/34] logging-log4j2 git commit: LOG4J2-1373 update Logger wrapper
Generate tool for new methods added to the Logger interface
Posted by rg...@apache.org.
LOG4J2-1373 update Logger wrapper Generate tool for new methods added to the Logger interface
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/31c76c7f
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/31c76c7f
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/31c76c7f
Branch: refs/heads/LOG4j2-494
Commit: 31c76c7f3dcc3fd9eafc7709763ed7094e1d6372
Parents: bb53479
Author: rpopma <rp...@apache.org>
Authored: Sat Apr 23 11:41:55 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:30 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/core/tools/Generate.java | 467 ++++++++++++++++++-
1 file changed, 449 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/31c76c7f/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
index ac62c51..c86004d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
@@ -72,6 +72,7 @@ public final class Generate {
+ "/**%n" //
+ " * Custom Logger interface with convenience methods for%n" //
+ " * %s%n" //
+ + " * <p>Compatible with Log4j 2.6 or higher.</p>%n" //
+ " */%n" //
+ "public final class %s implements Serializable {%n" //
+ " private static final long serialVersionUID = " + System.nanoTime() + "L;%n" //
@@ -117,6 +118,7 @@ public final class Generate {
+ "/**%n" //
+ " * Extended Logger interface with convenience methods for%n" //
+ " * %s%n" //
+ + " * <p>Compatible with Log4j 2.6 or higher.</p>%n" //
+ " */%n" //
+ "public final class %s extends ExtendedLoggerWrapper {%n" //
+ " private static final long serialVersionUID = " + System.nanoTime() + "L;%n" //
@@ -190,8 +192,9 @@ public final class Generate {
+ " * a warning if mismatched.%n" //
+ " * @return The custom Logger.%n" //
+ " */%n" //
- + " public static CLASSNAME create(final Class<?> loggerName, final MessageFactory factory) {%n" //
- + " final Logger wrapped = LogManager.getLogger(loggerName, factory);%n" //
+ + " public static CLASSNAME create(final Class<?> loggerName, final MessageFactory" //
+ + " messageFactory) {%n" //
+ + " final Logger wrapped = LogManager.getLogger(loggerName, messageFactory);%n" //
+ " return new CLASSNAME(wrapped);%n" //
+ " }%n" //
+ "%n" //
@@ -221,8 +224,8 @@ public final class Generate {
+ " * a warning if mismatched.%n" //
+ " * @return The custom Logger.%n" //
+ " */%n" //
- + " public static CLASSNAME create(final Object value, final MessageFactory factory) {%n" //
- + " final Logger wrapped = LogManager.getLogger(value, factory);%n" //
+ + " public static CLASSNAME create(final Object value, final MessageFactory messageFactory) {%n" //
+ + " final Logger wrapped = LogManager.getLogger(value, messageFactory);%n" //
+ " return new CLASSNAME(wrapped);%n" //
+ " }%n" //
+ "%n" //
@@ -248,8 +251,8 @@ public final class Generate {
+ " * a warning if mismatched.%n" //
+ " * @return The custom Logger.%n" //
+ " */%n" //
- + " public static CLASSNAME create(final String name, final MessageFactory factory) {%n" //
- + " final Logger wrapped = LogManager.getLogger(name, factory);%n" //
+ + " public static CLASSNAME create(final String name, final MessageFactory messageFactory) {%n" //
+ + " final Logger wrapped = LogManager.getLogger(name, messageFactory);%n" //
+ " return new CLASSNAME(wrapped);%n" //
+ " }%n";
@@ -287,6 +290,17 @@ public final class Generate {
+ " }%n" //
+ "%n" //
+ " /**%n" //
+ + " * Logs a message CharSequence with the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message CharSequence to log.%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final CharSequence message) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, (Throwable) null);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ " * Logs a message at the {@code CUSTOM_LEVEL} level including the stack trace of%n" //
+ " * the {@link Throwable} {@code t} passed as parameter.%n" //
+ " * %n" //
@@ -299,6 +313,19 @@ public final class Generate {
+ " }%n" //
+ "%n" //
+ " /**%n" //
+ + " * Logs a message at the {@code CUSTOM_LEVEL} level including the stack trace of%n" //
+ + " * the {@link Throwable} {@code t} passed as parameter.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the CharSequence to log.%n" //
+ + " * @param t the exception to log, including its stack trace.%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final CharSequence message, final Throwable t) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, t);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ " * Logs a message object with the {@code CUSTOM_LEVEL} level.%n" //
+ " * %n" //
+ " * @param marker the marker data specific to this log statement%n" //
@@ -321,6 +348,202 @@ public final class Generate {
+ " }%n" //
+ "%n" //
+ " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final String message, final Object p0) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, p0);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final String message, final Object p0, " //
+ + "final Object p1) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, p0, p1);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final String message, final Object p0, " //
+ + "final Object p1, final Object p2) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, p0, p1, p2);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, p0, p1, p2, p3);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, p0, p1, p2, p3, p4);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @param p5 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4, final Object p5) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, p0, p1, p2, p3, p4, p5);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @param p5 parameter to the message.%n" //
+ + " * @param p6 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4, final Object p5, final Object p6) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, p0, p1, p2, p3, p4, p5, p6);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @param p5 parameter to the message.%n" //
+ + " * @param p6 parameter to the message.%n" //
+ + " * @param p7 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4, final Object p5, final Object p6,%n" //
+ + " final Object p7) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, p0, p1, p2, p3, p4, p5, p6, p7);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @param p5 parameter to the message.%n" //
+ + " * @param p6 parameter to the message.%n" //
+ + " * @param p7 parameter to the message.%n" //
+ + " * @param p8 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4, final Object p5, final Object p6,%n" //
+ + " final Object p7, final Object p8) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, " //
+ + "p8);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param marker the marker data specific to this log statement%n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @param p5 parameter to the message.%n" //
+ + " * @param p6 parameter to the message.%n" //
+ + " * @param p7 parameter to the message.%n" //
+ + " * @param p8 parameter to the message.%n" //
+ + " * @param p9 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final Marker marker, final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4, final Object p5, final Object p6,%n" //
+ + " final Object p7, final Object p8, final Object p9) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, message, p0, p1, p2, p3, p4, p5, p6, p7, " //
+ + "p8, p9);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ " * Logs a message at the {@code CUSTOM_LEVEL} level including the stack trace of%n" //
+ " * the {@link Throwable} {@code t} passed as parameter.%n" //
+ " * %n" //
@@ -372,6 +595,28 @@ public final class Generate {
+ " }%n" //
+ "%n" //
+ " /**%n" //
+ + " * Logs a message CharSequence with the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message CharSequence to log.%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final CharSequence message) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, (Throwable) null);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a CharSequence at the {@code CUSTOM_LEVEL} level including the stack trace of%n" //
+ + " * the {@link Throwable} {@code t} passed as parameter.%n" //
+ + " * %n" //
+ + " * @param message the CharSequence to log.%n" //
+ + " * @param t the exception to log, including its stack trace.%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final CharSequence message, final Throwable t) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, t);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ " * Logs a message object with the {@code CUSTOM_LEVEL} level.%n" //
+ " * %n" //
+ " * @param message the message object to log.%n" //
@@ -392,6 +637,192 @@ public final class Generate {
+ " }%n" //
+ "%n" //
+ " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final String message, final Object p0) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, p0);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final String message, final Object p0, " //
+ + "final Object p1) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, p0, p1);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final String message, final Object p0, " //
+ + "final Object p1, final Object p2) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, p0, p1, p2);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, p0, p1, p2, p3);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, p0, p1, p2, p3, p4);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @param p5 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4, final Object p5) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, p0, p1, p2, p3, p4, p5);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @param p5 parameter to the message.%n" //
+ + " * @param p6 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4, final Object p5, final Object p6) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, p0, p1, p2, p3, p4, p5, p6);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @param p5 parameter to the message.%n" //
+ + " * @param p6 parameter to the message.%n" //
+ + " * @param p7 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4, final Object p5, final Object p6,%n" //
+ + " final Object p7) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, p0, p1, p2, p3, p4, p5, p6, p7);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @param p5 parameter to the message.%n" //
+ + " * @param p6 parameter to the message.%n" //
+ + " * @param p7 parameter to the message.%n" //
+ + " * @param p8 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4, final Object p5, final Object p6,%n" //
+ + " final Object p7, final Object p8) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, p0, p1, p2, p3, p4, p5, p6, p7, " //
+ + "p8);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ + " * Logs a message with parameters at the {@code CUSTOM_LEVEL} level.%n" //
+ + " * %n" //
+ + " * @param message the message to log; the format depends on the message factory.%n" //
+ + " * @param p0 parameter to the message.%n" //
+ + " * @param p1 parameter to the message.%n" //
+ + " * @param p2 parameter to the message.%n" //
+ + " * @param p3 parameter to the message.%n" //
+ + " * @param p4 parameter to the message.%n" //
+ + " * @param p5 parameter to the message.%n" //
+ + " * @param p6 parameter to the message.%n" //
+ + " * @param p7 parameter to the message.%n" //
+ + " * @param p8 parameter to the message.%n" //
+ + " * @param p9 parameter to the message.%n" //
+ + " * @see #getMessageFactory()%n" //
+ + " * @since Log4j-2.6%n" //
+ + " */%n" //
+ + " public void methodName(final String message, final Object p0, " //
+ + "final Object p1, final Object p2,%n" //
+ + " final Object p3, final Object p4, final Object p5, final Object p6,%n" //
+ + " final Object p7, final Object p8, final Object p9) {%n" //
+ + " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, p0, p1, p2, p3, p4, p5, p6, p7, " //
+ + "p8, p9);%n" //
+ + " }%n" //
+ + "%n" //
+ + " /**%n" //
+ " * Logs a message at the {@code CUSTOM_LEVEL} level including the stack trace of%n" //
+ " * the {@link Throwable} {@code t} passed as parameter.%n" //
+ " * %n" //
@@ -408,7 +839,7 @@ public final class Generate {
+ " *%n" //
+ " * @param msgSupplier A function, which when called, produces the desired log message;%n" //
+ " * the format depends on the message factory.%n" //
- + " * @since 2.4%n" //
+ + " * @since Log4j-2.4%n" //
+ " */%n" //
+ " public void methodName(final Supplier<?> msgSupplier) {%n" //
+ " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, msgSupplier, (Throwable) null);%n" //
@@ -421,7 +852,7 @@ public final class Generate {
+ " * @param msgSupplier A function, which when called, produces the desired log message;%n" //
+ " * the format depends on the message factory.%n" //
+ " * @param t the exception to log, including its stack trace.%n" //
- + " * @since 2.4%n" //
+ + " * @since Log4j-2.4%n" //
+ " */%n" //
+ " public void methodName(final Supplier<?> msgSupplier, final Throwable t) {%n" //
+ " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, msgSupplier, t);%n" //
@@ -434,7 +865,7 @@ public final class Generate {
+ " * @param marker the marker data specific to this log statement%n" //
+ " * @param msgSupplier A function, which when called, produces the desired log message;%n" //
+ " * the format depends on the message factory.%n" //
- + " * @since 2.4%n" //
+ + " * @since Log4j-2.4%n" //
+ " */%n" //
+ " public void methodName(final Marker marker, final Supplier<?> msgSupplier) {%n" //
+ " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, msgSupplier, (Throwable) null);%n" //
@@ -448,7 +879,7 @@ public final class Generate {
+ " * @param message the message to log; the format depends on the message factory.%n" //
+ " * @param paramSuppliers An array of functions, which when called, produce the desired log" //
+ " message parameters.%n" //
- + " * @since 2.4%n" //
+ + " * @since Log4j-2.4%n" //
+ " */%n" //
+ " public void methodName(final Marker marker, final String message, final Supplier<?>..." //
+ " paramSuppliers) {%n" //
@@ -464,7 +895,7 @@ public final class Generate {
+ " * @param msgSupplier A function, which when called, produces the desired log message;%n" //
+ " * the format depends on the message factory.%n" //
+ " * @param t A Throwable or null.%n" //
- + " * @since 2.4%n" //
+ + " * @since Log4j-2.4%n" //
+ " */%n" //
+ " public void methodName(final Marker marker, final Supplier<?> msgSupplier, final Throwable t) {%n" //
+ " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, msgSupplier, t);%n" //
@@ -477,7 +908,7 @@ public final class Generate {
+ " * @param message the message to log; the format depends on the message factory.%n" //
+ " * @param paramSuppliers An array of functions, which when called, produce the desired log" //
+ " message parameters.%n" //
- + " * @since 2.4%n" //
+ + " * @since Log4j-2.4%n" //
+ " */%n" //
+ " public void methodName(final String message, final Supplier<?>... paramSuppliers) {%n" //
+ " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, message, paramSuppliers);%n" //
@@ -490,7 +921,7 @@ public final class Generate {
+ " *%n" //
+ " * @param marker the marker data specific to this log statement%n" //
+ " * @param msgSupplier A function, which when called, produces the desired log message.%n" //
- + " * @since 2.4%n" //
+ + " * @since Log4j-2.4%n" //
+ " */%n" //
+ " public void methodName(final Marker marker, final MessageSupplier msgSupplier) {%n" //
+ " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, marker, msgSupplier, (Throwable) null);%n" //
@@ -505,7 +936,7 @@ public final class Generate {
+ " * @param marker the marker data specific to this log statement%n" //
+ " * @param msgSupplier A function, which when called, produces the desired log message.%n" //
+ " * @param t A Throwable or null.%n" //
- + " * @since 2.4%n" //
+ + " * @since Log4j-2.4%n" //
+ " */%n" //
+ " public void methodName(final Marker marker, final MessageSupplier msgSupplier, final " //
+ "Throwable t) {%n" //
@@ -518,7 +949,7 @@ public final class Generate {
+ " * {@link MessageFactory} to construct the {@code Message}.%n"
+ " *%n" //
+ " * @param msgSupplier A function, which when called, produces the desired log message.%n" //
- + " * @since 2.4%n" //
+ + " * @since Log4j-2.4%n" //
+ " */%n" //
+ " public void methodName(final MessageSupplier msgSupplier) {%n" //
+ " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, msgSupplier, (Throwable) null);%n" //
@@ -532,7 +963,7 @@ public final class Generate {
+ " *%n" //
+ " * @param msgSupplier A function, which when called, produces the desired log message.%n" //
+ " * @param t the exception to log, including its stack trace.%n" //
- + " * @since 2.4%n" //
+ + " * @since Log4j-2.4%n" //
+ " */%n" //
+ " public void methodName(final MessageSupplier msgSupplier, final Throwable t) {%n" //
+ " logger.logIfEnabled(FQCN, CUSTOM_LEVEL, null, msgSupplier, t);%n" //
@@ -549,7 +980,7 @@ public final class Generate {
/**
* Generates source code for custom logger wrappers that only provide convenience methods for the specified
* custom levels, not for the standard built-in levels.
- *
+ *
* @param args className of the custom logger to generate, followed by a NAME=intLevel pair for each custom log
* level to generate convenience methods for
*/
@@ -570,7 +1001,7 @@ public final class Generate {
/**
* Generates source code for extended logger wrappers that provide convenience methods for the specified custom
* levels.
- *
+ *
* @param args className of the custom logger to generate, followed by a NAME=intLevel pair for each custom log
* level to generate convenience methods for
*/
[19/34] logging-log4j2 git commit: LOG4J2-1334 don't take snapshot of
message, delegate to MutableLogEvent
Posted by rg...@apache.org.
LOG4J2-1334 don't take snapshot of message, delegate to MutableLogEvent
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e7fea765
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e7fea765
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e7fea765
Branch: refs/heads/LOG4j2-494
Commit: e7fea76570a1d30dd91cb9e54bfda13396d99f5e
Parents: b2e90dc
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:33:28 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:29 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/core/async/AsyncLoggerConfigDisruptor.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e7fea765/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
index 503e7d8..60494e0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
@@ -145,7 +145,7 @@ public class AsyncLoggerConfigDisruptor implements AsyncLoggerConfigDelegate {
private static final EventFactory<Log4jEventWrapper> MUTABLE_FACTORY = new EventFactory<Log4jEventWrapper>() {
@Override
public Log4jEventWrapper newInstance() {
- return new Log4jEventWrapper(new MutableLogEvent(new Object[10]));
+ return new Log4jEventWrapper(new MutableLogEvent());
}
};
@@ -324,8 +324,6 @@ public class AsyncLoggerConfigDisruptor implements AsyncLoggerConfigDelegate {
final LogEvent logEvent = ensureImmutable(event);
if (logEvent instanceof Log4jLogEvent && logEvent.getMessage() instanceof ReusableMessage) {
((Log4jLogEvent) logEvent).makeMessageImmutable();
- } else if (!Constants.FORMAT_MESSAGES_IN_BACKGROUND) { // LOG4J2-898: user may choose
- logEvent.getMessage().getFormattedMessage(); // LOG4J2-763: ask message to freeze parameters
}
return logEvent;
}
[31/34] logging-log4j2 git commit: LOG4J2-1297 added initial
performance test results: synchronous logging throughput
Posted by rg...@apache.org.
LOG4J2-1297 added initial performance test results: synchronous logging throughput
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7730ae5e
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7730ae5e
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7730ae5e
Branch: refs/heads/LOG4j2-494
Commit: 7730ae5eed9b7296e38b9d60578365d2cae9e39b
Parents: f226b97
Author: rpopma <rp...@apache.org>
Authored: Mon Apr 25 23:44:10 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:30 2016 -0700
----------------------------------------------------------------------
.../garbage-free2.6-SyncThroughputLinux.png | Bin 0 -> 70039 bytes
src/site/xdoc/manual/garbagefree.xml | 30 +++++++++++++++----
2 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7730ae5e/src/site/resources/images/garbage-free2.6-SyncThroughputLinux.png
----------------------------------------------------------------------
diff --git a/src/site/resources/images/garbage-free2.6-SyncThroughputLinux.png b/src/site/resources/images/garbage-free2.6-SyncThroughputLinux.png
new file mode 100644
index 0000000..5de5d9f
Binary files /dev/null and b/src/site/resources/images/garbage-free2.6-SyncThroughputLinux.png differ
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7730ae5e/src/site/xdoc/manual/garbagefree.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/garbagefree.xml b/src/site/xdoc/manual/garbagefree.xml
index 66cd532..c9e8692 100644
--- a/src/site/xdoc/manual/garbagefree.xml
+++ b/src/site/xdoc/manual/garbagefree.xml
@@ -352,12 +352,32 @@ public void garbageFree() {
</subsection>
<a name="Performance" />
<subsection name="Performance">
-
<a name="Latency" />
- <h4>TBD what to include here</h4>
- <p>Async Loggers 2.5 vs 2.6 in garbage-free mode</p>
- <p>Log4j 2.6 synchronous logging "classic" versus garbage-free mode - impact of adding threads</p>
- <p>Comparison with other logging libraries?</p>
+ <h4>Response Time of Garbage-free Logging is Consistently Better with Fewer Spikes</h4>
+ <p>TODO: add latency histogram: Response time distribution of Async Loggers 2.5 vs 2.6 in garbage-free mode under various loads.</p>
+ <p>TODO: add latency histogram: Response time distribution of synchronous logging vs 2.6 in garbage-free mode under various loads.</p>
+
+ <a name="Throughput" />
+ <h4>Throughput of Garbage-free Logging May Be Worse (But It's All Relative)</h4>
+ <p>Log4j 2.6 in garbage-free mode has the highest throughput in single-threaded scenarios. In multi-threaded
+ scenarios, Log4j 2.6 "classic" has highest throughput, with Log4j 2.6 in garbage-free mode and Log4j 2.5
+ not far behind. Our test results suggest that the throughput of all other logging frameworks rapidly
+ declines in multi-threaded applications.</p>
+ <p>The graph below compares Log4j 2.6 in garbage-free mode to Log4j 2.6 "classic" mode (which allocates
+ temporary objects for every logging call), Log4j 2.5, Log4j 1.2.17, Logback 1.1.7 and
+ Java util logging (JUL) on Oracle Java 1.8.0_45. All Log4j 2.x results use the RandomAccessFile appender.
+ Log4j 1.2.17, Logback and JUL use their respective File appenders. ImmediateFlush was set to <tt>false</tt> for all
+ loggers that support this. The JUL results are for the <tt>XMLFormatter</tt> (which in our measurements was
+ about twice as fast as the <tt>SimpleFormatter</tt>).</p>
+ <p>The synchronous logging throughput results below are generated with the
+ <a href="http://openjdk.java.net/projects/code-tools/jmh/">JMH</a> Java benchmark harness.
+ See the <tt>org.apache.logging.log4j.perf.jmh.FileAppenderBenchmark</tt> source code in the log4j-perf module.</p>
+ <p><img src="../images/garbage-free2.6-SyncThroughputLinux.png"
+ alt="Throughput of Log4j 2.6 in garbage-free mode is slightly worse than in classic mode, but on par with 2.5 and much better than alternatives logging libraries" /></p>
+ <p>(TODO: DOUBLE-CHECK) The above results are for <em>synchronous</em> logging. For <em>asynchronous</em> logging,
+ there was no measurable difference in throughput between
+ Log4j 2.6 in garbage-free mode and Log4j 2.6 in "classic" mode (allocating
+ new objects on every logging call).</p>
</subsection>
<a name="UnderTheHood" />
<subsection name="Under the Hood">
[34/34] logging-log4j2 git commit: LOG4J2-1297 improve instructions
on how to run this test
Posted by rg...@apache.org.
LOG4J2-1297 improve instructions on how to run this test
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fd01615c
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fd01615c
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fd01615c
Branch: refs/heads/LOG4j2-494
Commit: fd01615c2fc7c8dedcb7d87651a2308ab8bef8e3
Parents: fdaefaa
Author: rpopma <rp...@apache.org>
Authored: Tue Apr 26 00:40:23 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:31 2016 -0700
----------------------------------------------------------------------
.../apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fd01615c/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
index 5fbac7e..daccb12 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
@@ -39,7 +39,10 @@ import org.slf4j.LoggerFactory;
* for each uses a FileAppender
*/
// HOW TO RUN THIS TEST
-// java -jar target/benchmarks.jar ".*FileAppenderBenchmark.*" -f 1 -i 5 -wi 5 -bm sample -tu ns
+// java -jar log4j-perf/target/benchmarks.jar ".*FileAppenderBenchmark.*" -f 1 -wi 10 -i 20
+//
+// RUNNING THIS TEST WITH 4 THREADS:
+// java -jar log4j-perf/target/benchmarks.jar ".*FileAppenderBenchmark.*" -f 1 -wi 10 -i 20 -t 4
@State(Scope.Thread)
public class FileAppenderBenchmark {
public static final String MESSAGE = "This is a debug message";
[03/34] logging-log4j2 git commit: javadoc
Posted by rg...@apache.org.
javadoc
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9159e846
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9159e846
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9159e846
Branch: refs/heads/LOG4j2-494
Commit: 9159e84675699923505cecd11399f4f9bcad73eb
Parents: 287d2c6
Author: rpopma <rp...@apache.org>
Authored: Thu Apr 21 14:22:02 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:27 2016 -0700
----------------------------------------------------------------------
.../log4j/core/async/perftest/IdleStrategy.java | 24 +-------------------
.../core/async/perftest/NoOpIdleStrategy.java | 7 ++++--
2 files changed, 6 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9159e846/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/IdleStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/IdleStrategy.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/IdleStrategy.java
index eca115c..65b97df 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/IdleStrategy.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/IdleStrategy.java
@@ -19,11 +19,6 @@ package org.apache.logging.log4j.core.async.perftest;
/**
* Idle strategy for use by threads when they do not have work to do.
*
- * <h3>Note regarding implementor state</h3>
- *
- * Some implementations are known to be stateful, please note that you cannot safely assume implementations to be stateless.
- * Where implementations are stateful it is recommended that implementation state is padded to avoid false sharing.
- *
* <h3>Note regarding potential for TTSP(Time To Safe Point) issues</h3>
*
* If the caller spins in a 'counted' loop, and the implementation does not include a a safepoint poll this may cause a TTSP
@@ -36,24 +31,7 @@ package org.apache.logging.log4j.core.async.perftest;
*/
interface IdleStrategy {
/**
- * Perform current idle action (e.g. nothing/yield/sleep). To be used in conjunction with {@link IdleStrategy#reset()}
- * to clear internal state when idle period is over (or before it begins). Callers are expected to follow this pattern:
- *
- * <pre>
- * <code>while (isRunning) {
- * if (!hasWork()) {
- * idleStrategy.reset();
- * while (!hasWork()) {
- * if (!isRunning) {
- * return;
- * }
- * idleStrategy.idle();
- * }
- * }
- * doWork();
- * }
- * </code>
- * </pre>
+ * Perform current idle action (e.g. nothing/yield/sleep).
*/
void idle();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9159e846/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/NoOpIdleStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/NoOpIdleStrategy.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/NoOpIdleStrategy.java
index ad5d280..6bce312 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/NoOpIdleStrategy.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/NoOpIdleStrategy.java
@@ -17,8 +17,11 @@
package org.apache.logging.log4j.core.async.perftest;
/**
- * Low-latency idle strategy to be employed in loops that do significant work on each iteration such that any work in the
- * idle strategy would be wasteful.
+ * No operation idle strategy.
+ * <p>
+ * This idle strategy should be prevented from being inlined by using a Hotspot compiler command as a JVM argument e.g:
+ * <code>-XX:CompileCommand=dontinline,org.apache.logging.log4j.core.async.perftest.NoOpIdleStrategy::idle</code>
+ * </p>
*/
class NoOpIdleStrategy implements IdleStrategy {
[07/34] logging-log4j2 git commit: LOG4J2-1342 bugfix: don't set
ReusableParameterizedMessage array to null
Posted by rg...@apache.org.
LOG4J2-1342 bugfix: don't set ReusableParameterizedMessage array to null
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fb5e7305
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fb5e7305
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fb5e7305
Branch: refs/heads/LOG4j2-494
Commit: fb5e7305796d18d7a69ec2ce1a76ad6ae793e77c
Parents: 79e51b2
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 12:50:28 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:28 2016 -0700
----------------------------------------------------------------------
.../apache/logging/log4j/core/async/RingBufferLogEvent.java | 6 ++++--
.../org/apache/logging/log4j/core/impl/MutableLogEvent.java | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fb5e7305/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
index 72ae8ac..ab5e3d0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
@@ -115,8 +115,10 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
if (msg instanceof ReusableMessage) {
ReusableMessage reusable = (ReusableMessage) msg;
reusable.formatTo(getMessageTextForWriting());
- parameters = reusable.swapParameters(parameters);
- parameterCount = reusable.getParameterCount();
+ if (parameters != null) {
+ parameters = reusable.swapParameters(parameters);
+ parameterCount = reusable.getParameterCount();
+ }
} else {
// if the Message instance is reused, there is no point in freezing its message here
if (!Constants.FORMAT_MESSAGES_IN_BACKGROUND && msg != null) { // LOG4J2-898: user may choose
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fb5e7305/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
index 0393b0c..e256723 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
@@ -188,8 +188,10 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
if (msg instanceof ReusableMessage) {
ReusableMessage reusable = (ReusableMessage) msg;
reusable.formatTo(getMessageTextForWriting());
- parameters = reusable.swapParameters(parameters);
- parameterCount = reusable.getParameterCount();
+ if (parameters != null) {
+ parameters = reusable.swapParameters(parameters);
+ parameterCount = reusable.getParameterCount();
+ }
} else {
// if the Message instance is reused, there is no point in freezing its message here
if (!Constants.FORMAT_MESSAGES_IN_BACKGROUND && msg != null) { // LOG4J2-898: user may choose
[29/34] logging-log4j2 git commit: LOG4J2-1373 updated change log
Posted by rg...@apache.org.
LOG4J2-1373 updated change log
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2db215b7
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2db215b7
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2db215b7
Branch: refs/heads/LOG4j2-494
Commit: 2db215b7bfa080aa83e6c9a805c0cfc2b1e72aa0
Parents: be8779b
Author: rpopma <rp...@apache.org>
Authored: Sat Apr 23 15:42:43 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:30 2016 -0700
----------------------------------------------------------------------
src/changes/changes.xml | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2db215b7/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 0edfea6..4c23f35 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
</properties>
<body>
<release version="2.6" date="2016-MM-DD" description="GA Release 2.6">
+ <action issue="LOG4J2-1373" dev="rpopma" type="add">
+ (GC) Update Logger wrapper Generator tool to generate methods for the new Logger methods.
+ </action>
<action issue="LOG4J2-1372" dev="rgoers" type="fix" due-to="Kamal Mettananda, Gary Gregory">
XMLLayout indents, but not the first child tag (Event).
</action>
[22/34] logging-log4j2 git commit: LOG4J2-1342 added implementation
of new method #memento(), ensure internal parameters field is not null
Posted by rg...@apache.org.
LOG4J2-1342 added implementation of new method #memento(), ensure internal parameters field is not null
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/710c34d6
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/710c34d6
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/710c34d6
Branch: refs/heads/LOG4j2-494
Commit: 710c34d6cc4332b351ab818b0e1240b92613f26a
Parents: 185dce2
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:38:04 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:29 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/core/impl/MutableLogEvent.java | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/710c34d6/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
index e256723..7fd31c0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/MutableLogEvent.java
@@ -27,6 +27,7 @@ import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.message.ReusableMessage;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.util.Strings;
@@ -60,10 +61,11 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
private ThreadContext.ContextStack contextStack;
public MutableLogEvent() {
- this(null);
+ this(new StringBuilder(Constants.INITIAL_REUSABLE_MESSAGE_SIZE), new Object[10]);
}
- public MutableLogEvent(final Object[] replacementParameters) {
+ public MutableLogEvent(final StringBuilder msgText, final Object[] replacementParameters) {
+ this.messageText = msgText;
this.parameters = replacementParameters;
}
@@ -273,6 +275,15 @@ public class MutableLogEvent implements LogEvent, ReusableMessage {
}
@Override
+ public Message memento() {
+ if (message != null) {
+ return message;
+ }
+ Object[] params = parameters == null ? new Object[0] : Arrays.copyOf(parameters, parameterCount);
+ return new ParameterizedMessage(messageText.toString(), params);
+ }
+
+ @Override
public Throwable getThrown() {
return thrown;
}
[21/34] logging-log4j2 git commit: LOG4J2-1342 added implementation
of new method #memento()
Posted by rg...@apache.org.
LOG4J2-1342 added implementation of new method #memento()
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/d80793b3
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d80793b3
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d80793b3
Branch: refs/heads/LOG4j2-494
Commit: d80793b35721855d5f03eeb0b5706e64f4469a84
Parents: 8f3c146
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:37:07 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:29 2016 -0700
----------------------------------------------------------------------
.../org/apache/logging/log4j/message/ReusableObjectMessage.java | 5 +++++
.../logging/log4j/message/ReusableParameterizedMessage.java | 5 +++++
.../org/apache/logging/log4j/message/ReusableSimpleMessage.java | 5 +++++
3 files changed, 15 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d80793b3/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
index 920eff4..fddc0eb 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java
@@ -110,4 +110,9 @@ public class ReusableObjectMessage implements ReusableMessage {
public short getParameterCount() {
return 0;
}
+
+ @Override
+ public Message memento() {
+ return new ObjectMessage(obj);
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d80793b3/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
index 12f4346..24c0e7d 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
@@ -76,6 +76,11 @@ public class ReusableParameterizedMessage implements ReusableMessage {
return (short) argCount;
}
+ @Override
+ public Message memento() {
+ return new ParameterizedMessage(messagePattern, getTrimmedParams());
+ }
+
private void init(final String messagePattern, final int argCount, final Object[] paramArray) {
this.varargs = null;
this.messagePattern = messagePattern;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d80793b3/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
index 9fae16c..d894ef7 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableSimpleMessage.java
@@ -80,6 +80,11 @@ public class ReusableSimpleMessage implements ReusableMessage, CharSequence {
return 0;
}
+ @Override
+ public Message memento() {
+ return new SimpleMessage(charSequence);
+ }
+
// CharSequence impl
@Override
[15/34] logging-log4j2 git commit: LOG4J2-1334 synchronous logging is
now garbage-free; enable this by default
Posted by rg...@apache.org.
LOG4J2-1334 synchronous logging is now garbage-free; enable this by default
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/22e98d60
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/22e98d60
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/22e98d60
Branch: refs/heads/LOG4j2-494
Commit: 22e98d608d11b950bc90c582d996fbe94822329b
Parents: 04ee75f
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:54:09 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:29 2016 -0700
----------------------------------------------------------------------
.../java/org/apache/logging/log4j/core/config/LoggerConfig.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/22e98d60/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
index 7b030c6..3a3e04c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
@@ -84,7 +84,7 @@ public class LoggerConfig extends AbstractFilterable {
}
}
if (LOG_EVENT_FACTORY == null) {
- LOG_EVENT_FACTORY = false //Constants.ENABLE_THREADLOCALS
+ LOG_EVENT_FACTORY = Constants.ENABLE_THREADLOCALS
? new ReusableLogEventFactory()
: new DefaultLogEventFactory();
}
[33/34] logging-log4j2 git commit: LOG4J2-1297 minor edits
Posted by rg...@apache.org.
LOG4J2-1297 minor edits
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fdaefaa5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fdaefaa5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fdaefaa5
Branch: refs/heads/LOG4j2-494
Commit: fdaefaa50b81ab3fb0fff487c381f1afab799fda
Parents: 26d87c3
Author: rpopma <rp...@apache.org>
Authored: Mon Apr 25 23:51:45 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:31 2016 -0700
----------------------------------------------------------------------
src/site/xdoc/manual/garbagefree.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fdaefaa5/src/site/xdoc/manual/garbagefree.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/garbagefree.xml b/src/site/xdoc/manual/garbagefree.xml
index 6222a45..c6cf8ca 100644
--- a/src/site/xdoc/manual/garbagefree.xml
+++ b/src/site/xdoc/manual/garbagefree.xml
@@ -361,8 +361,8 @@ public void garbageFree() {
<h4>Throughput of Garbage-free Logging May Be Worse (But It's All Relative)</h4>
<p>In our measurements, Log4j 2.6 in garbage-free mode had the highest throughput in single-threaded scenarios. In multi-threaded
scenarios, Log4j 2.6 "classic" had the highest throughput, with Log4j 2.6 in garbage-free mode and Log4j 2.5
- not far behind. Our test results suggest that the throughput of all other logging frameworks rapidly
- declines in multi-threaded applications.</p>
+ not far behind. Our test results suggest that the throughput of the other logging frameworks we tested
+ will rapidly decline in multi-threaded applications.</p>
<p>The graph below compares Log4j 2.6 in garbage-free mode to Log4j 2.6 "classic" mode (which allocates
temporary objects for every logging call), Log4j 2.5, Log4j 1.2.17, Logback 1.1.7 and
Java util logging (JUL) on Oracle Java 1.8.0_45. All Log4j 2.x results use the RandomAccessFile appender.
[05/34] logging-log4j2 git commit: [LOG4J2-1372] XMLLayout indents,
but not the first child tag (Event).
Posted by rg...@apache.org.
[LOG4J2-1372] XMLLayout indents, but not the first child tag (Event).
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/1d12bf0e
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/1d12bf0e
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/1d12bf0e
Branch: refs/heads/LOG4j2-494
Commit: 1d12bf0e32c41597d8f4a138bea36d146a534126
Parents: f7909e2
Author: ggregory <gg...@apache.org>
Authored: Wed Apr 20 09:17:28 2016 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:27 2016 -0700
----------------------------------------------------------------------
.../log4j/core/layout/JacksonFactory.java | 39 +++++++++-
.../appender/XmlCompleteFileAppenderTest.java | 82 ++++++++++++++++++++
.../core/appender/XmlFileAppenderTest.java | 1 +
src/changes/changes.xml | 3 +
4 files changed, 124 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1d12bf0e/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
index 763f42a..3b34957 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
@@ -19,12 +19,15 @@ package org.apache.logging.log4j.core.layout;
import java.util.HashSet;
import java.util.Set;
+import javax.xml.stream.XMLStreamException;
+
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
import org.apache.logging.log4j.core.jackson.JsonConstants;
import org.apache.logging.log4j.core.jackson.Log4jJsonObjectMapper;
import org.apache.logging.log4j.core.jackson.Log4jXmlObjectMapper;
import org.apache.logging.log4j.core.jackson.Log4jYamlObjectMapper;
import org.apache.logging.log4j.core.jackson.XmlConstants;
+import org.codehaus.stax2.XMLStreamWriter2;
import com.fasterxml.jackson.core.PrettyPrinter;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
@@ -72,6 +75,8 @@ abstract class JacksonFactory {
static class XML extends JacksonFactory {
+ static final int DEFAULT_INDENT = 1;
+
@Override
protected String getPropertNameForContextMap() {
return XmlConstants.ELT_CONTEXT_MAP;
@@ -100,7 +105,7 @@ abstract class JacksonFactory {
@Override
protected PrettyPrinter newPrettyPrinter() {
- return new DefaultXmlPrettyPrinter();
+ return new Log4jXmlPrettyPrinter(DEFAULT_INDENT);
}
}
@@ -137,6 +142,38 @@ abstract class JacksonFactory {
}
}
+ /**
+ * When <Event>s are written into a XML file; the "Event" object is not the root element, but an element named
+ * <Events> created using {@link #getHeader()} and {@link #getFooter()} methods.<br/>
+ * {@link com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter} is used to print the Event object into
+ * XML; hence it assumes <Event> tag as the root element, so it prints the <Event> tag without any
+ * indentation. To add an indentation to the <Event> tag; hence an additional indentation for any
+ * sub-elements, this class is written. As an additional task, to avoid the blank line printed after the ending
+ * </Event> tag, {@link #writePrologLinefeed(XMLStreamWriter2)} method is also overridden.
+ */
+ static class Log4jXmlPrettyPrinter extends DefaultXmlPrettyPrinter {
+
+ private static final long serialVersionUID = 1L;
+
+ Log4jXmlPrettyPrinter(int nesting) {
+ _nesting = nesting;
+ }
+
+ @Override
+ public void writePrologLinefeed(XMLStreamWriter2 sw) throws XMLStreamException {
+ // nothing
+ }
+
+ /**
+ * Sets the nesting level to 1 rather than 0, so the "Event" tag will get indentation of next level below root.
+ */
+ @Override
+ public DefaultXmlPrettyPrinter createInstance() {
+ return new Log4jXmlPrettyPrinter(XML.DEFAULT_INDENT);
+ }
+
+ }
+
abstract protected String getPropertNameForContextMap();
abstract protected String getPropertNameForSource();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1d12bf0e/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
index 344b221..2b7fc92 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompleteFileAppenderTest.java
@@ -57,6 +57,7 @@ public class XmlCompleteFileAppenderTest {
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
line1 = reader.readLine();
line2 = reader.readLine();
+ reader.readLine(); // ignore the empty line after the <Events> root
line3 = reader.readLine();
line4 = reader.readLine();
} finally {
@@ -81,4 +82,85 @@ public class XmlCompleteFileAppenderTest {
final String location = "testFlushAtEndOfBatch";
assertTrue("no location", !line1.contains(location));
}
+
+ /**
+ * Test the indentation of the Events XML.
+ * <p>Expected Events XML is as below.</p>
+ * <pre>
+<?xml version="1.0" encoding="UTF-8"?>
+<Events xmlns="http://logging.apache.org/log4j/2.0/events">
+
+ <Event xmlns="http://logging.apache.org/log4j/2.0/events" timeMillis="1460974522088" thread="main" level="INFO" loggerName="com.foo.Bar" endOfBatch="false" loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="11" threadPriority="5">
+ <Message>First Msg tag must be in level 2 after correct indentation</Message>
+ </Event>
+
+ <Event xmlns="http://logging.apache.org/log4j/2.0/events" timeMillis="1460974522089" thread="main" level="INFO" loggerName="com.foo.Bar" endOfBatch="true" loggerFqcn="org.apache.logging.log4j.spi.AbstractLogger" threadId="11" threadPriority="5">
+ <Message>Second Msg tag must also be in level 2 after correct indentation</Message>
+ </Event>
+</Events>
+ * </pre>
+ * @throws Exception
+ */
+ @Test
+ public void testChildElementsAreCorrectlyIndented() throws Exception {
+ final File file = new File("target", "XmlCompleteFileAppenderTest.log");
+ file.delete();
+ final Logger log = LogManager.getLogger("com.foo.Bar");
+ final String firstLogMsg = "First Msg tag must be in level 2 after correct indentation";
+ log.info(firstLogMsg);
+ final String secondLogMsg = "Second Msg tag must also be in level 2 after correct indentation";
+ log.info(secondLogMsg);
+ CoreLoggerContexts.stopLoggerContext(false, file); // stop async thread
+
+ String[] lines = new String[9];
+
+ try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
+
+ int usefulLinesIndex = 0;
+ String readLine;
+ while((readLine = reader.readLine()) != null) {
+
+ if (!"".equals(readLine.trim())) {
+ lines[usefulLinesIndex] = readLine;
+ usefulLinesIndex++;
+ }
+ }
+ } finally {
+ file.delete();
+ }
+
+ String currentLine = lines[0];
+ assertFalse("line1 incorrect: [" + currentLine + "], must have no indentation", currentLine.startsWith(" "));
+ // <EVENTS
+ currentLine = lines[1];
+ assertFalse("line2 incorrect: [" + currentLine + "], must have no indentation", currentLine.startsWith(" "));
+ // <EVENT
+ currentLine = lines[2];
+ assertTrue("line3 incorrect: [" + currentLine + "], must have two-space indentation", currentLine.startsWith(" "));
+ assertFalse("line3 incorrect: [" + currentLine + "], must not have more than two-space indentation", currentLine.startsWith(" "));
+ // <MSG
+ currentLine = lines[3];
+ assertTrue("line4 incorrect: [" + currentLine + "], must have four-space indentation", currentLine.startsWith(" "));
+ assertFalse("line4 incorrect: [" + currentLine + "], must not have more than four-space indentation", currentLine.startsWith(" "));
+ // </EVENT
+ currentLine = lines[4];
+ assertTrue("line5 incorrect: [" + currentLine + "], must have two-space indentation", currentLine.startsWith(" "));
+ assertFalse("line5 incorrect: [" + currentLine + "], must not have more than two-space indentation", currentLine.startsWith(" "));
+
+ // <EVENT
+ currentLine = lines[5];
+ assertTrue("line6 incorrect: [" + currentLine + "], must have two-space indentation", currentLine.startsWith(" "));
+ assertFalse("line6 incorrect: [" + currentLine + "], must not have more than two-space indentation", currentLine.startsWith(" "));
+ // <MSG
+ currentLine = lines[6];
+ assertTrue("line7 incorrect: [" + currentLine + "], must have four-space indentation", currentLine.startsWith(" "));
+ assertFalse("line7 incorrect: [" + currentLine + "], must not have more than four-space indentation", currentLine.startsWith(" "));
+ // </EVENT
+ currentLine = lines[7];
+ assertTrue("line8 incorrect: [" + currentLine + "], must have two-space indentation", currentLine.startsWith(" "));
+ assertFalse("line8 incorrect: [" + currentLine + "], must not have more than two-space indentation", currentLine.startsWith(" "));
+ // </EVENTS
+ currentLine = lines[8];
+ assertFalse("line9 incorrect: [" + currentLine + "], must have no indentation", currentLine.startsWith(" "));
+ }
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1d12bf0e/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlFileAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlFileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlFileAppenderTest.java
index b509b30..c3c04d8 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlFileAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/XmlFileAppenderTest.java
@@ -54,6 +54,7 @@ public class XmlFileAppenderTest {
String line2;
String line3;
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
+ reader.readLine(); // first line is empty, so ignore it
line1 = reader.readLine();
line2 = reader.readLine();
line3 = reader.readLine();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1d12bf0e/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index cb717ed..0edfea6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,9 @@
</properties>
<body>
<release version="2.6" date="2016-MM-DD" description="GA Release 2.6">
+ <action issue="LOG4J2-1372" dev="rgoers" type="fix" due-to="Kamal Mettananda, Gary Gregory">
+ XMLLayout indents, but not the first child tag (Event).
+ </action>
<action issue="LOG4J2-1363" dev="rgoers" type="fix">
Properties Configuration did not support includeLocation attribute on Loggers.
</action>
[16/34] logging-log4j2 git commit: LOG4J2-1334 enable unit tests that
verify that synchronous logging and mixed sync/async is garbage-free
Posted by rg...@apache.org.
LOG4J2-1334 enable unit tests that verify that synchronous logging and mixed sync/async is garbage-free
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/bc81c74b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/bc81c74b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/bc81c74b
Branch: refs/heads/LOG4j2-494
Commit: bc81c74b96925baf13dd34f5d4ac3776b6e3387b
Parents: 22e98d6
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:54:53 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:29 2016 -0700
----------------------------------------------------------------------
.../apache/logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java | 2 --
.../apache/logging/log4j/core/GcFreeSynchronousLoggingTest.java | 2 --
2 files changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/bc81c74b/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 b917f93..c18861b 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
@@ -26,8 +26,6 @@ import org.junit.Test;
*/
public class GcFreeMixedSyncAyncLoggingTest {
- // Ignore until mixed synchronous/asynchronous logging is gc-free
- @Ignore
@Test
public void testNoAllocationDuringSteadyStateLogging() throws Throwable {
GcFreeLoggingTestUtil.runTest(getClass());
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/bc81c74b/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 9a01c22..731c2af 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
@@ -26,8 +26,6 @@ import org.junit.Test;
*/
public class GcFreeSynchronousLoggingTest {
- // Ignore until synchronous logging is gc-free
- @Ignore
@Test
public void testNoAllocationDuringSteadyStateLogging() throws Throwable {
GcFreeLoggingTestUtil.runTest(getClass());
[23/34] logging-log4j2 git commit: LOG4J2-1297 small syntax edits
Posted by rg...@apache.org.
LOG4J2-1297 small syntax edits
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/26d87c37
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/26d87c37
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/26d87c37
Branch: refs/heads/LOG4j2-494
Commit: 26d87c37236ff200d57e18d5bebb41491fa945c8
Parents: 7730ae5
Author: rpopma <rp...@apache.org>
Authored: Mon Apr 25 23:49:21 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:30 2016 -0700
----------------------------------------------------------------------
src/site/xdoc/manual/garbagefree.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/26d87c37/src/site/xdoc/manual/garbagefree.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/garbagefree.xml b/src/site/xdoc/manual/garbagefree.xml
index c9e8692..6222a45 100644
--- a/src/site/xdoc/manual/garbagefree.xml
+++ b/src/site/xdoc/manual/garbagefree.xml
@@ -359,8 +359,8 @@ public void garbageFree() {
<a name="Throughput" />
<h4>Throughput of Garbage-free Logging May Be Worse (But It's All Relative)</h4>
- <p>Log4j 2.6 in garbage-free mode has the highest throughput in single-threaded scenarios. In multi-threaded
- scenarios, Log4j 2.6 "classic" has highest throughput, with Log4j 2.6 in garbage-free mode and Log4j 2.5
+ <p>In our measurements, Log4j 2.6 in garbage-free mode had the highest throughput in single-threaded scenarios. In multi-threaded
+ scenarios, Log4j 2.6 "classic" had the highest throughput, with Log4j 2.6 in garbage-free mode and Log4j 2.5
not far behind. Our test results suggest that the throughput of all other logging frameworks rapidly
declines in multi-threaded applications.</p>
<p>The graph below compares Log4j 2.6 in garbage-free mode to Log4j 2.6 "classic" mode (which allocates
@@ -369,7 +369,7 @@ public void garbageFree() {
Log4j 1.2.17, Logback and JUL use their respective File appenders. ImmediateFlush was set to <tt>false</tt> for all
loggers that support this. The JUL results are for the <tt>XMLFormatter</tt> (which in our measurements was
about twice as fast as the <tt>SimpleFormatter</tt>).</p>
- <p>The synchronous logging throughput results below are generated with the
+ <p>The synchronous logging throughput results below are obtained with the
<a href="http://openjdk.java.net/projects/code-tools/jmh/">JMH</a> Java benchmark harness.
See the <tt>org.apache.logging.log4j.perf.jmh.FileAppenderBenchmark</tt> source code in the log4j-perf module.</p>
<p><img src="../images/garbage-free2.6-SyncThroughputLinux.png"
[24/34] logging-log4j2 git commit: LOG4J2-1374 & LOG4J2-1375: Migrate
tests from Logback 1.1.3 to 1.1.7, Update SLF4J from 1.7.13 to 1.7.21
Posted by rg...@apache.org.
LOG4J2-1374 & LOG4J2-1375: Migrate tests from Logback 1.1.3 to 1.1.7, Update SLF4J from 1.7.13 to 1.7.21
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/66cc0c83
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/66cc0c83
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/66cc0c83
Branch: refs/heads/LOG4j2-494
Commit: 66cc0c839101424fc7c79659d9abf4c402c871a6
Parents: 2db215b
Author: rpopma <rp...@apache.org>
Authored: Sat Apr 23 20:12:12 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:30 2016 -0700
----------------------------------------------------------------------
pom.xml | 4 ++--
src/changes/changes.xml | 6 ++++++
2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/66cc0c83/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index df4140d..8815982 100644
--- a/pom.xml
+++ b/pom.xml
@@ -187,8 +187,8 @@
<!-- <Log4jReleaseManager>Matt Sicker</Log4jReleaseManager>
<Log4jReleaseKey>FA1C814D</Log4jReleaseKey> -->
<!-- note that any properties you want available in velocity templates must not use periods! -->
- <slf4jVersion>1.7.13</slf4jVersion>
- <logbackVersion>1.1.3</logbackVersion>
+ <slf4jVersion>1.7.21</slf4jVersion>
+ <logbackVersion>1.1.7</logbackVersion>
<jackson1Version>1.9.13</jackson1Version>
<jackson2Version>2.7.3</jackson2Version>
<springVersion>3.2.13.RELEASE</springVersion>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/66cc0c83/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4c23f35..c5831c0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,12 @@
</properties>
<body>
<release version="2.6" date="2016-MM-DD" description="GA Release 2.6">
+ <action issue="LOG4J2-1375" dev="rpopma" type="update">
+ Update SLF4J from 1.7.13 to 1.7.21.
+ </action>
+ <action issue="LOG4J2-1374" dev="rpopma" type="update">
+ Migrate tests from Logback 1.1.3 to 1.1.7.
+ </action>
<action issue="LOG4J2-1373" dev="rpopma" type="add">
(GC) Update Logger wrapper Generator tool to generate methods for the new Logger methods.
</action>
[17/34] logging-log4j2 git commit: LOG4J2-1342
MutableLogEvent.getMessage() returns this log event if message is not set
Posted by rg...@apache.org.
LOG4J2-1342 MutableLogEvent.getMessage() returns this log event if message is not set
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c1729958
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c1729958
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c1729958
Branch: refs/heads/LOG4j2-494
Commit: c17299589cdf16f8680323dd5d2c58f7530af85b
Parents: 710c34d
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:38:49 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:29 2016 -0700
----------------------------------------------------------------------
.../org/apache/logging/log4j/core/impl/MutableLogEventTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c1729958/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
index 40e13e8..8f7b4ef 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java
@@ -102,7 +102,7 @@ public class MutableLogEventTest {
assertNull("fqcn", mutable.getLoggerFqcn());
assertNull("logger", mutable.getLoggerName());
assertNull("marker", mutable.getMarker());
- assertEquals("msg", new SimpleMessage(Strings.EMPTY), mutable.getMessage());
+ assertEquals("msg", mutable, mutable.getMessage());
assertEquals("nanoTm", 0, mutable.getNanoTime());
assertEquals("tid", 0, mutable.getThreadId());
assertNull("tname", mutable.getThreadName());
@@ -155,7 +155,7 @@ public class MutableLogEventTest {
assertNull("fqcn", mutable.getLoggerFqcn());
assertNull("logger", mutable.getLoggerName());
assertNull("marker", mutable.getMarker());
- assertEquals("msg", new SimpleMessage(Strings.EMPTY), mutable.getMessage());
+ assertEquals("msg", mutable, mutable.getMessage());
assertNull("thrwn", mutable.getThrown());
assertNull("source", mutable.getSource());
[20/34] logging-log4j2 git commit: LOG4J2-1342 added implementation
of new method #memento()
Posted by rg...@apache.org.
LOG4J2-1342 added implementation of new method #memento()
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/185dce26
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/185dce26
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/185dce26
Branch: refs/heads/LOG4j2-494
Commit: 185dce2651653b8eb9923bed0ef4146305661476
Parents: d80793b
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:37:26 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:29 2016 -0700
----------------------------------------------------------------------
.../apache/logging/log4j/core/async/RingBufferLogEvent.java | 9 +++++++++
1 file changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/185dce26/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
index ab5e3d0..f687ff4 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
@@ -31,6 +31,7 @@ import org.apache.logging.log4j.core.impl.ThrowableProxy;
import org.apache.logging.log4j.core.lookup.StrSubstitutor;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.message.ReusableMessage;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.message.TimestampMessage;
@@ -265,6 +266,14 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen
return parameterCount;
}
+ @Override
+ public Message memento() {
+ if (message != null) {
+ return message;
+ }
+ Object[] params = parameters == null ? new Object[0] : Arrays.copyOf(parameters, parameterCount);
+ return new ParameterizedMessage(messageText.toString(), params);
+ }
// CharSequence impl
[26/34] logging-log4j2 git commit: LOG4J2-1297 throughput test
improvements (added JUL,
separated parameterized message from simple string logging)
Posted by rg...@apache.org.
LOG4J2-1297 throughput test improvements (added JUL, separated parameterized message from simple string logging)
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f226b972
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f226b972
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f226b972
Branch: refs/heads/LOG4j2-494
Commit: f226b97225030a4dca658d5f7cd52b50aa21a721
Parents: 66cc0c8
Author: rpopma <rp...@apache.org>
Authored: Sun Apr 24 22:58:37 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:30 2016 -0700
----------------------------------------------------------------------
.../log4j/perf/jmh/FileAppenderBenchmark.java | 92 +++++-----
.../perf/jmh/FileAppenderParamsBenchmark.java | 170 +++++++++++++++++++
2 files changed, 210 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f226b972/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
index 9bea11e..5fbac7e 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
@@ -17,6 +17,11 @@
package org.apache.logging.log4j.perf.jmh;
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.FileHandler;
+import java.util.logging.Level;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openjdk.jmh.annotations.Benchmark;
@@ -29,43 +34,41 @@ import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.util.concurrent.TimeUnit;
-
/**
- * Benchmarks Log4j 2, Log4j 1, and Logback using the DEBUG level which is enabled for this test. The configuration
+ * Benchmarks Log4j 2, Log4j 1, Logback and JUL using the DEBUG level which is enabled for this test. The configuration
* for each uses a FileAppender
*/
// HOW TO RUN THIS TEST
// java -jar target/benchmarks.jar ".*FileAppenderBenchmark.*" -f 1 -i 5 -wi 5 -bm sample -tu ns
@State(Scope.Thread)
public class FileAppenderBenchmark {
+ public static final String MESSAGE = "This is a debug message";
+ private FileHandler julFileHandler;
+
Logger log4j2Logger;
Logger log4j2RandomLogger;
org.slf4j.Logger slf4jLogger;
org.apache.log4j.Logger log4j1Logger;
- int j;
+ java.util.logging.Logger julLogger;
@Setup
- public void setUp() {
+ public void setUp() throws Exception {
System.setProperty("log4j.configurationFile", "log4j2-perf.xml");
System.setProperty("log4j.configuration", "log4j12-perf.xml");
System.setProperty("logback.configurationFile", "logback-perf.xml");
- File logbackFile = new File("target/testlogback.log");
- logbackFile.delete();
- File log4jFile = new File ("target/testlog4j.log");
- log4jFile.delete();
- File log4j2File = new File ("target/testlog4j2.log");
- log4j2File.delete();
- File log4j2RAF = new File ("target/testRandomlog4j2.log");
- log4j2RAF.delete();
+ deleteLogFiles();
log4j2Logger = LogManager.getLogger(FileAppenderBenchmark.class);
log4j2RandomLogger = LogManager.getLogger("TestRandom");
slf4jLogger = LoggerFactory.getLogger(FileAppenderBenchmark.class);
log4j1Logger = org.apache.log4j.Logger.getLogger(FileAppenderBenchmark.class);
- j = 0;
+
+ julFileHandler = new FileHandler("target/testJulLog.log");
+ julLogger = java.util.logging.Logger.getLogger(getClass().getName());
+ julLogger.setUseParentHandlers(false);
+ julLogger.addHandler(julFileHandler);
+ julLogger.setLevel(Level.ALL);
}
@TearDown
@@ -74,6 +77,10 @@ public class FileAppenderBenchmark {
System.clearProperty("log4j.configuration");
System.clearProperty("logback.configurationFile");
+ deleteLogFiles();
+ }
+
+ private void deleteLogFiles() {
File logbackFile = new File("target/testlogback.log");
logbackFile.delete();
File log4jFile = new File ("target/testlog4j.log");
@@ -82,63 +89,44 @@ public class FileAppenderBenchmark {
log4jRandomFile.delete();
File log4j2File = new File ("target/testlog4j2.log");
log4j2File.delete();
+ File julFile = new File("target/testJulLog.log");
+ julFile.delete();
}
@BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.MILLISECONDS)
- @Benchmark
- public boolean baseline() {
- ++j;
- return true;
- }
-
- @BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.MILLISECONDS)
- @Benchmark
- public void log4j2RAFStringConcatenation() {
- log4j2RandomLogger.debug("This is a debug [" + ++j + "] message");
- }
-
-
- @BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @OutputTimeUnit(TimeUnit.SECONDS)
@Benchmark
- public void log4j2StringConcatenation() {
- log4j2Logger.debug("This is a debug [" + ++j + "] message");
+ public void log4j2RAF() {
+ log4j2RandomLogger.debug(MESSAGE);
}
- @BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.MILLISECONDS)
- @Benchmark
- public void slf4jStringConcatenation() {
- slf4jLogger.debug("This is a debug [" + ++j + "] message");
- }
@BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @OutputTimeUnit(TimeUnit.SECONDS)
@Benchmark
- public void log4j1StringConcatenation() {
- log4j1Logger.debug("This is a debug [" + ++j + "] message");
+ public void log4j2File() {
+ log4j2Logger.debug(MESSAGE);
}
@BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @OutputTimeUnit(TimeUnit.SECONDS)
@Benchmark
- public void log4j2RAFParameterizedString() {
- log4j2RandomLogger.debug("This is a debug [{}] message", ++j);
+ public void logbackFile() {
+ slf4jLogger.debug(MESSAGE);
}
@BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @OutputTimeUnit(TimeUnit.SECONDS)
@Benchmark
- public void log4j2ParameterizedString() {
- log4j2Logger.debug("This is a debug [{}] message", ++j);
+ public void log4j1File() {
+ log4j1Logger.debug(MESSAGE);
}
@BenchmarkMode(Mode.Throughput)
- @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @OutputTimeUnit(TimeUnit.SECONDS)
@Benchmark
- public void slf4jParameterizedString() {
- slf4jLogger.debug("This is a debug [{}] message", ++j);
+ public void julFile() {
+ // must specify sourceClass or JUL will look it up by walking the stack trace!
+ julLogger.logp(Level.INFO, getClass().getName(), "julFile", MESSAGE);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f226b972/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderParamsBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderParamsBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderParamsBenchmark.java
new file mode 100644
index 0000000..6865381
--- /dev/null
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderParamsBenchmark.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.perf.jmh;
+
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.FileHandler;
+import java.util.logging.Level;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.logging.log4j.util.Unbox.*;
+
+/**
+ * Benchmarks Log4j 2, Log4j 1, Logback and JUL using the DEBUG level which is enabled for this test. The configuration
+ * for each uses a FileAppender
+ */
+// HOW TO RUN THIS TEST
+// java -jar target/benchmarks.jar ".*FileAppenderParamsBenchmark.*" -f 1 -i 5 -wi 5 -bm sample -tu ns
+@State(Scope.Thread)
+public class FileAppenderParamsBenchmark {
+ private FileHandler julFileHandler;
+ Logger log4j2Logger;
+ Logger log4j2RandomLogger;
+ org.slf4j.Logger slf4jLogger;
+ org.apache.log4j.Logger log4j1Logger;
+ java.util.logging.Logger julLogger;
+ int j, k, m;
+
+ @Setup
+ public void setUp() throws Exception {
+ System.setProperty("log4j.configurationFile", "log4j2-perf.xml");
+ System.setProperty("log4j.configuration", "log4j12-perf.xml");
+ System.setProperty("logback.configurationFile", "logback-perf.xml");
+
+ deleteLogFiles();
+
+ log4j2Logger = LogManager.getLogger(getClass());
+ log4j2RandomLogger = LogManager.getLogger("TestRandom");
+ slf4jLogger = LoggerFactory.getLogger(getClass());
+ log4j1Logger = org.apache.log4j.Logger.getLogger(getClass());
+
+ julFileHandler = new FileHandler("target/testJulLog.log");
+ julLogger = java.util.logging.Logger.getLogger(getClass().getName());
+ julLogger.setUseParentHandlers(false);
+ julLogger.addHandler(julFileHandler);
+ julLogger.setLevel(Level.ALL);
+ j = 0;
+ }
+
+ @TearDown
+ public void tearDown() {
+ System.clearProperty("log4j.configurationFile");
+ System.clearProperty("log4j.configuration");
+ System.clearProperty("logback.configurationFile");
+
+ deleteLogFiles();
+ }
+
+ private void deleteLogFiles() {
+ File logbackFile = new File("target/testlogback.log");
+ logbackFile.delete();
+ File log4jFile = new File ("target/testlog4j.log");
+ log4jFile.delete();
+ File log4jRandomFile = new File ("target/testRandomlog4j2.log");
+ log4jRandomFile.delete();
+ File log4j2File = new File ("target/testlog4j2.log");
+ log4j2File.delete();
+ File julFile = new File("target/testJulLog.log");
+ julFile.delete();
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.SECONDS)
+ @Benchmark
+ public void param1Log4j1Concat() {
+ log4j1Logger.debug("This is a debug [" + ++j + "] message");
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.SECONDS)
+ @Benchmark
+ public void param3Log4j1Concat() {
+ log4j1Logger.debug("Val1=" + ++j + ", val2=" + ++k + ", val3=" + ++m);
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.SECONDS)
+ @Benchmark
+ public void param1Log4j2RAF() {
+ log4j2RandomLogger.debug("This is a debug [{}] message", box(++j));
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.SECONDS)
+ @Benchmark
+ public void param3Log4j2RAF() {
+ log4j2RandomLogger.debug("Val1={}, val2={}, val3={}", box(++j), box(++k), box(++m));
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.SECONDS)
+ @Benchmark
+ public void param1Log4j2File() {
+ log4j2Logger.debug("This is a debug [{}] message", box(++j));
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.SECONDS)
+ @Benchmark
+ public void param3Log4j2File() {
+ log4j2Logger.debug("Val1={}, val2={}, val3={}", box(++j), box(++k), box(++m));
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.SECONDS)
+ @Benchmark
+ public void param1LogbackFile() {
+ slf4jLogger.debug("This is a debug [{}] message", ++j);
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.SECONDS)
+ @Benchmark
+ public void param3LogbackFile() {
+ slf4jLogger.debug("Val1={}, val2={}, val3={}", (++j), (++k), (++m));
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.SECONDS)
+ @Benchmark
+ public void param1JulFile() {
+ // must specify sourceClass or JUL will look it up by walking the stack trace!
+ julLogger.logp(Level.INFO, getClass().getName(), "param1JulFile", "This is a debug [{}] message", ++j);
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.SECONDS)
+ @Benchmark
+ public void param3JulFile() {
+ // must specify sourceClass or JUL will look it up by walking the stack trace!
+ julLogger.logp(Level.INFO, getClass().getName(), "param3JulFile", "Val1={}, val2={}, val3={}",
+ new Object[]{++j, ++k, ++m});
+ }
+}
[30/34] logging-log4j2 git commit: LOG4J2-1373 added comment on
@since versioning convention in generated code
Posted by rg...@apache.org.
LOG4J2-1373 added comment on @since versioning convention in generated code
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/be8779b9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/be8779b9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/be8779b9
Branch: refs/heads/LOG4j2-494
Commit: be8779b9c8f2265f3cfe34229ee461261f40a71e
Parents: 31c76c7
Author: rpopma <rp...@apache.org>
Authored: Sat Apr 23 15:42:24 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:30 2016 -0700
----------------------------------------------------------------------
.../main/java/org/apache/logging/log4j/core/tools/Generate.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/be8779b9/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
index c86004d..b1ca676 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/Generate.java
@@ -44,6 +44,9 @@ import java.util.List;
* DEFCON3=550}
*/
public final class Generate {
+ // Implementation note:
+ // The generated code is in the user's namespace which has its own versioning scheme, so
+ // any @since tags in the generated code deliberately mention "Log4j-2.x" rather than just the log4j version number.
static final String PACKAGE_DECLARATION = "package %s;%n%n";
[11/34] logging-log4j2 git commit: LOG4J2-1342 added tests to verify
parameters are passed correctly with async logging
Posted by rg...@apache.org.
LOG4J2-1342 added tests to verify parameters are passed correctly with async logging
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/873e19b4
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/873e19b4
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/873e19b4
Branch: refs/heads/LOG4j2-494
Commit: 873e19b4258032a253cc5baee03b4919fc170397
Parents: 6ef68fa
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 12:08:38 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:28 2016 -0700
----------------------------------------------------------------------
.../layout/CsvParameterLayoutAllAsyncTest.java | 69 ++++++++++++++++++
.../core/layout/CsvParameterLayoutTest.java | 73 ++++++++++++--------
.../src/test/resources/csvParamsMixedAsync.xml | 13 ++++
log4j-core/src/test/resources/csvParamsSync.xml | 29 ++++++++
4 files changed, 156 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/873e19b4/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java
new file mode 100644
index 0000000..0ef2e1d
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutAllAsyncTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.layout;
+
+import org.apache.commons.csv.CSVFormat;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.async.AsyncLoggerContextSelector;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.util.Constants;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.util.Strings;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests {@link AbstractCsvLayout} with all loggers async.
+ *
+ * @since 2.6
+ */
+public class CsvParameterLayoutAllAsyncTest {
+
+ @BeforeClass
+ public static void beforeClass() {
+ System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR,
+ AsyncLoggerContextSelector.class.getName());
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
+ "AsyncLoggerTest.xml");
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
+ }
+
+
+ @Test
+ public void testLayoutDefaultNormal() throws Exception {
+ Logger root = (Logger) LogManager.getRootLogger();
+ CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), false);
+ }
+
+ @Test
+ public void testLayoutDefaultObjectArrayMessage() throws Exception {
+ Logger root = (Logger) LogManager.getRootLogger();
+ CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), true);
+ }
+
+ @Test
+ public void testLayoutTab() throws Exception {
+ Logger root = (Logger) LogManager.getRootLogger();
+ CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createLayout(CSVFormat.TDF), true);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/873e19b4/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
index 5f58d79..ce3abfc 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvParameterLayoutTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.logging.log4j.core.layout;
-import static org.junit.Assert.assertEquals;
-
import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -26,43 +26,49 @@ import org.apache.commons.csv.CSVFormat;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.BasicConfigurationFactory;
import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.junit.LoggerContextRule;
import org.apache.logging.log4j.message.ObjectArrayMessage;
import org.apache.logging.log4j.test.appender.ListAppender;
import org.junit.AfterClass;
import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.junit.Assert.*;
/**
* Tests {@link AbstractCsvLayout}.
*
* @since 2.4
*/
+@RunWith(value = Parameterized.class)
public class CsvParameterLayoutTest {
- static ConfigurationFactory cf = new BasicConfigurationFactory();
+ @Parameterized.Parameters(name = "{0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(
+ new Object[][]{
+ { new LoggerContextRule("csvParamsSync.xml"), },
+ { new LoggerContextRule("csvParamsMixedAsync.xml"), },
+ }
+ );
+ }
- @AfterClass
- public static void cleanupClass() {
- ConfigurationFactory.removeConfigurationFactory(cf);
- ThreadContext.clearAll();
+ @Rule
+ public final LoggerContextRule init;
+
+ public CsvParameterLayoutTest(final LoggerContextRule contextRule) {
+ this.init = contextRule;
}
- @BeforeClass
- public static void setupClass() {
+ @AfterClass
+ public static void cleanupClass() {
+// System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, null);
ThreadContext.clearAll();
- ConfigurationFactory.setConfigurationFactory(cf);
- final LoggerContext ctx = LoggerContext.getContext();
- ctx.reconfigure();
}
- private final LoggerContext ctx = LoggerContext.getContext();
-
- private final Logger root = ctx.getLogger("");
-
@Test
public void testCustomCharset() {
final AbstractCsvLayout layout = CsvParameterLayout.createLayout(null, "Excel", null, null, null, null, null,
@@ -82,7 +88,7 @@ public class CsvParameterLayoutTest {
assertEquals("text/csv; charset=UTF-8", layout.getContentType());
}
- private void testLayoutNormalApi(final AbstractCsvLayout layout, boolean messageApi) throws Exception {
+ static void testLayoutNormalApi(final Logger root, final AbstractCsvLayout layout, boolean messageApi) throws Exception {
final Map<String, Appender> appenders = root.getAppenders();
for (final Appender appender : appenders.values()) {
root.removeAppender(appender);
@@ -97,11 +103,19 @@ public class CsvParameterLayoutTest {
// output messages
if (messageApi) {
- logDebugObjectArrayMessage();
+ logDebugObjectArrayMessage(root);
} else {
- logDebugNormalApi();
+ logDebugNormalApi(root);
+ }
+
+ // wait until background thread finished processing
+ int maxTries = 50;
+ while (appender.getMessages().size() < 4 && maxTries-- > 0) {
+ Thread.sleep(1L);
}
+ assertEquals("Background thread did not finish processing: msg count", 4, appender.getMessages().size());
+ // don't stop appender until background thread is done
appender.stop();
final List<String> list = appender.getMessages();
@@ -112,14 +126,14 @@ public class CsvParameterLayoutTest {
Assert.assertEquals("7" + d + "8" + d + "9" + d + "10", list.get(3));
}
- private void logDebugNormalApi() {
+ private static void logDebugNormalApi(final Logger root) {
root.debug("with placeholders: {}{}{}", 1, 2, 3);
root.debug("without placeholders", 2, 3);
root.debug(null, 5, 6);
root.debug("invalid placeholder count {}", 7, 8, 9, 10);
}
- private void logDebugObjectArrayMessage() {
+ private static void logDebugObjectArrayMessage(final Logger root) {
root.debug(new ObjectArrayMessage(1, 2, 3));
root.debug(new ObjectArrayMessage(2, 3));
root.debug(new ObjectArrayMessage(5, 6));
@@ -128,16 +142,19 @@ public class CsvParameterLayoutTest {
@Test
public void testLayoutDefaultNormal() throws Exception {
- testLayoutNormalApi(CsvParameterLayout.createDefaultLayout(), false);
+ Logger root = this.init.getLogger("");
+ testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), false);
}
@Test
public void testLayoutDefaultObjectArrayMessage() throws Exception {
- testLayoutNormalApi(CsvParameterLayout.createDefaultLayout(), true);
+ Logger root = this.init.getLogger("");
+ testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), true);
}
@Test
public void testLayoutTab() throws Exception {
- testLayoutNormalApi(CsvParameterLayout.createLayout(CSVFormat.TDF), true);
+ Logger root = this.init.getLogger("");
+ testLayoutNormalApi(root, CsvParameterLayout.createLayout(CSVFormat.TDF), true);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/873e19b4/log4j-core/src/test/resources/csvParamsMixedAsync.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/csvParamsMixedAsync.xml b/log4j-core/src/test/resources/csvParamsMixedAsync.xml
new file mode 100644
index 0000000..4d0811a
--- /dev/null
+++ b/log4j-core/src/test/resources/csvParamsMixedAsync.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="OFF">
+ <Appenders>
+ <List name="List">
+ <PatternLayout pattern="[%-5level] %c{1.} %msg%n" />
+ </List>
+ </Appenders>
+ <Loggers>
+ <AsyncRoot level="debug" includeLocation="false">
+ <appender-ref ref="List"/>
+ </AsyncRoot>
+ </Loggers>
+</Configuration>
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/873e19b4/log4j-core/src/test/resources/csvParamsSync.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/csvParamsSync.xml b/log4j-core/src/test/resources/csvParamsSync.xml
new file mode 100644
index 0000000..c2a92c3
--- /dev/null
+++ b/log4j-core/src/test/resources/csvParamsSync.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<Configuration status="WARN">
+ <Appenders>
+ <List name="List">
+ <PatternLayout pattern="[%-5level] %c{1.} %msg%n" />
+ </List>
+ </Appenders>
+ <Loggers>
+ <Root level="debug">
+ <AppenderRef ref="List" />
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
[32/34] logging-log4j2 git commit: Adding README.md file for GitHub
Posted by rg...@apache.org.
Adding README.md file for GitHub
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/bf3ef615
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/bf3ef615
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/bf3ef615
Branch: refs/heads/LOG4j2-494
Commit: bf3ef615ba165d26cd2ef556546830ce3c5a9d4c
Parents: fd01615
Author: Mikael Ståldal <mi...@magine.com>
Authored: Mon Apr 25 18:10:14 2016 +0200
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:31 2016 -0700
----------------------------------------------------------------------
README.md | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/bf3ef615/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d399485
--- /dev/null
+++ b/README.md
@@ -0,0 +1,20 @@
+# Apache Log4j 2
+
+Apache Log4j 2 is an upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x,
+and provides many of the improvements available in Logback while fixing some inherent problems in Logback's architecture.
+
+## Documentation
+
+The Log4j 2 User's Guide is available [here](http://logging.apache.org/log4j/2.x/manual/index.html) or as a downloadable
+[PDF](http://logging.apache.org/log4j/2.x/log4j-users-guide.pdf).
+
+## Requirements
+
+Log4j 2.4 and greater requires Java 7, versions 2.0-alpha1 to 2.3 required Java 6.
+Some features require optional dependencies; the documentation for these features specifies the dependencies.
+
+## License
+
+Apache Log4j 2 is distributed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
+
+
[04/34] logging-log4j2 git commit: [LOG4J2-1372] XMLLayout indents,
but not the first child tag (Event). Javadoc.
Posted by rg...@apache.org.
[LOG4J2-1372] XMLLayout indents, but not the first child tag (Event).
Javadoc.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/287d2c6b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/287d2c6b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/287d2c6b
Branch: refs/heads/LOG4j2-494
Commit: 287d2c6b861b2f938d0bb9dcebd897681bfb3520
Parents: 1d12bf0
Author: ggregory <gg...@apache.org>
Authored: Wed Apr 20 10:21:53 2016 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:27 2016 -0700
----------------------------------------------------------------------
.../org/apache/logging/log4j/core/layout/JacksonFactory.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/287d2c6b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
index 3b34957..ea0877f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/JacksonFactory.java
@@ -144,12 +144,14 @@ abstract class JacksonFactory {
/**
* When <Event>s are written into a XML file; the "Event" object is not the root element, but an element named
- * <Events> created using {@link #getHeader()} and {@link #getFooter()} methods.<br/>
+ * <Events> created using {@link XmlLayout#getHeader()} and {@link XmlLayout#getFooter()} methods.
+ * <p>
* {@link com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter} is used to print the Event object into
* XML; hence it assumes <Event> tag as the root element, so it prints the <Event> tag without any
* indentation. To add an indentation to the <Event> tag; hence an additional indentation for any
* sub-elements, this class is written. As an additional task, to avoid the blank line printed after the ending
* </Event> tag, {@link #writePrologLinefeed(XMLStreamWriter2)} method is also overridden.
+ * </p>
*/
static class Log4jXmlPrettyPrinter extends DefaultXmlPrettyPrinter {
[18/34] logging-log4j2 git commit: LOG4J2-1342 added method
ReusableMessage#memento() to take snapshot (used by AsyncAppender)
Posted by rg...@apache.org.
LOG4J2-1342 added method ReusableMessage#memento() to take snapshot (used by AsyncAppender)
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8f3c146e
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8f3c146e
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8f3c146e
Branch: refs/heads/LOG4j2-494
Commit: 8f3c146e33039f525eaf1559d200c982c6ebf4cf
Parents: e7fea76
Author: rpopma <rp...@apache.org>
Authored: Fri Apr 22 14:36:21 2016 +0900
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Mon Apr 25 21:30:29 2016 -0700
----------------------------------------------------------------------
.../org/apache/logging/log4j/message/ReusableMessage.java | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8f3c146e/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
index 0536b23..82e40ac 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
@@ -61,4 +61,12 @@ public interface ReusableMessage extends Message, StringBuilderFormattable {
* @return the current number of parameters
*/
short getParameterCount();
+
+ /**
+ * Returns an immutable snapshot of the current internal state of this reusable message. The returned snapshot
+ * will not be affected by subsequent modifications of this reusable message.
+ *
+ * @return an immutable snapshot of this message
+ */
+ Message memento();
}