You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2016/04/15 14:48:28 UTC
[1/7] logging-log4j2 git commit: Improved GelfLayoutBenchmark
Repository: logging-log4j2
Updated Branches:
refs/heads/LOG4J2-1365 02cde2759 -> 299f488dc
Improved GelfLayoutBenchmark
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/aaaaaad3
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/aaaaaad3
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/aaaaaad3
Branch: refs/heads/LOG4J2-1365
Commit: aaaaaad31cb24b3d6cdb078d491011baa5f0212b
Parents: 8f5e275
Author: Mikael Ståldal <mi...@magine.com>
Authored: Thu Apr 14 16:02:04 2016 +0200
Committer: Mikael Ståldal <mi...@magine.com>
Committed: Thu Apr 14 16:02:04 2016 +0200
----------------------------------------------------------------------
.../log4j/perf/jmh/GelfLayoutBenchmark.java | 67 +++++++++++++-----
.../logging/log4j/perf/util/DemoAppender.java | 71 ++++++++++++++++++++
.../src/main/resources/log4j2-gelf-perf.xml | 30 ---------
3 files changed, 122 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aaaaaad3/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/GelfLayoutBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/GelfLayoutBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/GelfLayoutBenchmark.java
index 870bc3d..ee2f143 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/GelfLayoutBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/GelfLayoutBenchmark.java
@@ -17,44 +17,79 @@
package org.apache.logging.log4j.perf.jmh;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.ThreadContext;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.core.layout.GelfLayout;
+import org.apache.logging.log4j.core.util.KeyValuePair;
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.SimpleMessage;
+import org.apache.logging.log4j.perf.util.DemoAppender;
import org.openjdk.jmh.annotations.*;
-import java.io.File;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
- * Benchmarks Log4j 2 GelfLayout with a FileAppender.
+ * Benchmarks Log4j 2 GelfLayout.
*/
// HOW TO RUN THIS TEST
// java -jar target/benchmarks.jar GelfLayoutBenchmark -f 1 -i 5 -wi 5 -bm sample -tu ns
@State(Scope.Thread)
public class GelfLayoutBenchmark {
- public static final String MESSAGE =
+ private static final CharSequence MESSAGE =
"This is rather long and chatty log message with quite some interesting information and a bit of fun in it which is suitable here";
+ private static final LogEvent EVENT = createLogEvent();
+ private static final KeyValuePair[] ADDITIONAL_FIELDS = new KeyValuePair[0];
- Logger log4j2Logger;
- org.apache.log4j.Logger log4j1Logger;
+ private static LogEvent createLogEvent() {
+ final Marker marker = null;
+ final String fqcn = "com.mycom.myproject.mypackage.MyClass";
+ final org.apache.logging.log4j.Level level = org.apache.logging.log4j.Level.DEBUG;
+ final Message message = new SimpleMessage(MESSAGE);
+ final Throwable t = null;
+ final Map<String, String> mdc = null;
+ final ThreadContext.ContextStack ndc = null;
+ final String threadName = null;
+ final StackTraceElement location = null;
+ final long timestamp = 12345678;
+
+ return Log4jLogEvent.newBuilder() //
+ .setLoggerName("name(ignored)") //
+ .setMarker(marker) //
+ .setLoggerFqcn(fqcn) //
+ .setLevel(level) //
+ .setMessage(message) //
+ .setThrown(t) //
+ .setContextMap(mdc) //
+ .setContextStack(ndc) //
+ .setThreadName(threadName) //
+ .setSource(location) //
+ .setTimeMillis(timestamp) //
+ .build();
+ }
+
+ Appender appender;
int j;
@Setup
public void setUp() {
- System.setProperty("log4j.configurationFile", "log4j2-gelf-perf.xml");
+ System.setProperty("log4j2.enable.direct.encoders", "true");
- File log4j2File = new File("target/testlog4j2.json");
- log4j2File.delete();
+ appender = new DemoAppender(new GelfLayout(
+ "host",
+ ADDITIONAL_FIELDS,
+ GelfLayout.CompressionType.OFF,
+ 0));
- log4j2Logger = LogManager.getLogger(GelfLayoutBenchmark.class);
j = 0;
}
@TearDown
public void tearDown() {
- System.clearProperty("log4j.configurationFile");
-
- File log4j2File = new File("target/testlog4j2.json");
- log4j2File.delete();
+ System.clearProperty("log4j2.enable.direct.encoders");
}
@BenchmarkMode(Mode.Throughput)
@@ -69,7 +104,7 @@ public class GelfLayoutBenchmark {
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Benchmark
public void log4j2Gelf() {
- log4j2Logger.debug(MESSAGE);
+ appender.append(EVENT);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aaaaaad3/log4j-perf/src/main/java/org/apache/logging/log4j/perf/util/DemoAppender.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/util/DemoAppender.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/util/DemoAppender.java
new file mode 100644
index 0000000..35171c2
--- /dev/null
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/util/DemoAppender.java
@@ -0,0 +1,71 @@
+/*
+ * 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.util;
+
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.layout.ByteBufferDestination;
+import org.apache.logging.log4j.core.util.Constants;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Demo Appender that does not do any I/O.
+ */
+public class DemoAppender extends AbstractAppender implements ByteBufferDestination {
+ private final ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[4096]);
+
+ public long checksum;
+
+ public DemoAppender(Layout<?> layout) {
+ super("demo", null, layout);
+ }
+
+ @Override
+ public void append(LogEvent event) {
+ if (Constants.ENABLE_DIRECT_ENCODERS) {
+ getLayout().encode(event, this);
+ drain(byteBuffer);
+ } else {
+ byte[] binary = getLayout().toByteArray(event);
+ consume(binary, 0, binary.length);
+ }
+ }
+
+ @Override
+ public ByteBuffer getByteBuffer() {
+ return byteBuffer;
+ }
+
+ @Override
+ public ByteBuffer drain(ByteBuffer buf) {
+ buf.flip();
+ consume(buf.array(), buf.position(), buf.limit());
+ buf.clear();
+ return buf;
+ }
+
+ private void consume(byte[] data, int offset, int length) {
+ // need to do something with the result or the JVM may optimize everything away
+ long sum = 0;
+ for (int i = offset; i < length; i++) {
+ sum += data[i];
+ }
+ checksum += sum;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aaaaaad3/log4j-perf/src/main/resources/log4j2-gelf-perf.xml
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/resources/log4j2-gelf-perf.xml b/log4j-perf/src/main/resources/log4j2-gelf-perf.xml
deleted file mode 100644
index 94c74e5..0000000
--- a/log4j-perf/src/main/resources/log4j2-gelf-perf.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?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 name="GelfPerfTest" status="error">
- <Appenders>
- <File name="TestLogfile" fileName="target/testlog4j2.json" immediateFlush="false">
- <GelfLayout compressionType="OFF"/>
- </File>
- </Appenders>
- <Loggers>
- <Root level="debug">
- <AppenderRef ref="TestLogfile"/>
- </Root>
- </Loggers>
-</Configuration>
\ No newline at end of file
[6/7] logging-log4j2 git commit: Merge branch 'master' into
LOG4J2-1365
Posted by mi...@apache.org.
Merge branch 'master' into LOG4J2-1365
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0ec82b7b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0ec82b7b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0ec82b7b
Branch: refs/heads/LOG4J2-1365
Commit: 0ec82b7b66bfd028eb11ab972a98b3e8555a167f
Parents: f68acc5 71fbda8
Author: Mikael Ståldal <mi...@magine.com>
Authored: Fri Apr 15 14:24:36 2016 +0200
Committer: Mikael Ståldal <mi...@magine.com>
Committed: Fri Apr 15 14:24:36 2016 +0200
----------------------------------------------------------------------
.../logging/log4j/core/impl/Log4jLogEvent.java | 14 +-
.../log4j/core/impl/MutableLogEvent.java | 171 +++++++++++++++++--
2 files changed, 166 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
[2/7] logging-log4j2 git commit: Merge branch 'master' into
LOG4J2-1365
Posted by mi...@apache.org.
Merge branch 'master' into LOG4J2-1365
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f68acc5c
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f68acc5c
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f68acc5c
Branch: refs/heads/LOG4J2-1365
Commit: f68acc5c77f0ac490fe3639f75061fe910fe26f9
Parents: 02cde27 aaaaaad
Author: Mikael Ståldal <mi...@magine.com>
Authored: Thu Apr 14 16:02:24 2016 +0200
Committer: Mikael Ståldal <mi...@magine.com>
Committed: Thu Apr 14 16:02:24 2016 +0200
----------------------------------------------------------------------
.../log4j/perf/jmh/GelfLayoutBenchmark.java | 67 +++++++++++++-----
.../logging/log4j/perf/util/DemoAppender.java | 71 ++++++++++++++++++++
.../src/main/resources/log4j2-gelf-perf.xml | 30 ---------
3 files changed, 122 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
[4/7] logging-log4j2 git commit: LOG4J2-1334 added
MutableLogEvent.clear() and initFrom() methods to prepare for this class
being used in the AsyncLoggerConfigDisruptor ring buffer
Posted by mi...@apache.org.
LOG4J2-1334 added MutableLogEvent.clear() and initFrom() methods to prepare for this class being used in the AsyncLoggerConfigDisruptor ring buffer
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/35d06895
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/35d06895
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/35d06895
Branch: refs/heads/LOG4J2-1365
Commit: 35d06895f9251e149d3a82066750a619699e5c7f
Parents: d2a79e0
Author: rpopma <rp...@apache.org>
Authored: Thu Apr 14 23:51:08 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Thu Apr 14 23:51:08 2016 +0900
----------------------------------------------------------------------
.../log4j/core/impl/MutableLogEvent.java | 171 +++++++++++++++++--
1 file changed, 155 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/35d06895/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 876ce58..5330c34 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
@@ -4,7 +4,12 @@ import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
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.ReusableMessage;
+import org.apache.logging.log4j.message.SimpleMessage;
+import org.apache.logging.log4j.util.PropertiesUtil;
+import org.apache.logging.log4j.util.Strings;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
@@ -13,7 +18,12 @@ import java.util.Map;
/**
* Mutable implementation of the {@code LogEvent} interface.
*/
-public class MutableLogEvent implements LogEvent {
+public class MutableLogEvent implements LogEvent, ReusableMessage {
+ private static final int INITIAL_REUSABLE_MESSAGE_SIZE = size("log4j.initialReusableMsgSize", 128);
+ private static final int MAX_REUSABLE_MESSAGE_SIZE = size("log4j.maxReusableMsgSize", (128 * 2 + 2) * 2 + 2);
+ private static final Object[] PARAMS = new Object[0];
+ private static final Message EMPTY = new SimpleMessage(Strings.EMPTY);
+
private String loggerFqcn;
private Marker marker;
private Level level;
@@ -29,8 +39,63 @@ public class MutableLogEvent implements LogEvent {
private boolean includeLocation;
private boolean endOfBatch = false;
private long nanoTime;
- // private ThrowableProxy thrownProxy;
- // private StackTraceElement source;
+ private ThrowableProxy thrownProxy;
+ private StackTraceElement source;
+ private StringBuilder messageText;
+
+ private static int size(final String property, final int defaultValue) {
+ return PropertiesUtil.getProperties().getIntegerProperty(property, defaultValue);
+ }
+
+ /**
+ * Initialize the fields of this {@code MutableLogEvent} from another event.
+ * Similar in purpose and usage as {@link org.apache.logging.log4j.core.impl.Log4jLogEvent.LogEventProxy},
+ * but a mutable version.
+ * <p>
+ * This method is used on async logger ringbuffer slots holding MutableLogEvent objects in each slot.
+ * </p>
+ *
+ * @param event the event to copy data from
+ */
+ public void initFrom(final LogEvent event) {
+ this.loggerFqcn = event.getLoggerFqcn();
+ this.marker = event.getMarker();
+ this.level = event.getLevel();
+ this.loggerName = event.getLoggerName();
+ this.timeMillis = event.getTimeMillis();
+ this.thrown = event.getThrown();
+ this.thrownProxy = event.getThrownProxy();
+ this.contextMap = event.getContextMap();
+ this.contextStack = event.getContextStack();
+ this.source = event.isIncludeLocation() ? event.getSource() : null;
+ this.threadId = event.getThreadId();
+ this.threadName = event.getThreadName();
+ this.threadPriority = event.getThreadPriority();
+ this.endOfBatch = event.isEndOfBatch();
+ this.nanoTime = event.getNanoTime();
+ setMessage(event.getMessage());
+ }
+
+ public void clear() {
+ loggerFqcn = null;
+ marker = null;
+ level = null;
+ loggerName = null;
+ message = null;
+ thrown = null;
+ thrownProxy = null;
+ source = null;
+ contextMap = null;
+ contextStack = null;
+ threadName = null;
+ // primitive fields that cannot be cleared:
+ //timeMillis;
+ //threadId;
+ //threadPriority;
+ //includeLocation;
+ //endOfBatch;
+ //nanoTime;
+ }
@Override
public String getLoggerFqcn() {
@@ -70,11 +135,72 @@ public class MutableLogEvent implements LogEvent {
@Override
public Message getMessage() {
+ if (message == null) {
+ return (messageText == null) ? EMPTY : this;
+ }
return message;
}
- public void setMessage(Message message) {
- this.message = message;
+ public void setMessage(final Message msg) {
+ if (msg instanceof ReusableMessage) {
+ ((ReusableMessage) msg).formatTo(getMessageTextForWriting());
+ } 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
+ msg.getFormattedMessage(); // LOG4J2-763: ask message to freeze parameters
+ }
+ this.message = msg;
+ }
+ }
+
+ private StringBuilder getMessageTextForWriting() {
+ if (messageText == null) {
+ // Should never happen:
+ // only happens if user logs a custom reused message when Constants.ENABLE_THREADLOCALS is false
+ messageText = new StringBuilder(INITIAL_REUSABLE_MESSAGE_SIZE);
+ }
+ messageText.setLength(0);
+ return messageText;
+ }
+
+ /**
+ * @see ReusableMessage#getFormattedMessage()
+ */
+ @Override
+ public String getFormattedMessage() {
+ return messageText.toString();
+ }
+
+ /**
+ * @see ReusableMessage#getFormat()
+ */
+ @Override
+ public String getFormat() {
+ return null;
+ }
+
+ /**
+ * @see ReusableMessage#getParameters()
+ */
+ @Override
+ public Object[] getParameters() {
+ return PARAMS;
+ }
+
+ /**
+ * @see ReusableMessage#getThrowable()
+ */
+ @Override
+ public Throwable getThrowable() {
+ return getThrown();
+ }
+
+ /**
+ * @see ReusableMessage#formatTo(StringBuilder)
+ */
+ @Override
+ public void formatTo(final StringBuilder buffer) {
+ buffer.append(messageText);
}
@Override
@@ -95,12 +221,33 @@ public class MutableLogEvent implements LogEvent {
this.timeMillis = timeMillis;
}
+ /**
+ * Returns the ThrowableProxy associated with the event, or null.
+ * @return The ThrowableProxy associated with the event.
+ */
@Override
public ThrowableProxy getThrownProxy() {
- if (thrown != null) {
- return new ThrowableProxy(thrown);
+ if (thrownProxy == null && thrown != null) {
+ thrownProxy = new ThrowableProxy(thrown);
}
- return null;
+ return thrownProxy;
+ }
+
+ /**
+ * Returns the StackTraceElement for the caller. This will be the entry that occurs right
+ * before the first occurrence of FQCN as a class name.
+ * @return the StackTraceElement for the caller.
+ */
+ @Override
+ public StackTraceElement getSource() {
+ if (source != null) {
+ return source;
+ }
+ if (loggerFqcn == null || !includeLocation) {
+ return null;
+ }
+ source = Log4jLogEvent.calcLocation(loggerFqcn);
+ return source;
}
@Override
@@ -149,14 +296,6 @@ public class MutableLogEvent implements LogEvent {
}
@Override
- public StackTraceElement getSource() {
- if (loggerFqcn == null || !includeLocation) {
- return null;
- }
- return Log4jLogEvent.calcLocation(loggerFqcn);
- }
-
- @Override
public boolean isIncludeLocation() {
return includeLocation;
}
[5/7] logging-log4j2 git commit: LOG4J2-1334 added
Log4jLogEvent.serialize(LogEvent,
boolean) method to allow serialization/copy of any LogEvent (regardless of
implementation)
Posted by mi...@apache.org.
LOG4J2-1334 added Log4jLogEvent.serialize(LogEvent, boolean) method to allow serialization/copy of any LogEvent (regardless of implementation)
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/71fbda80
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/71fbda80
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/71fbda80
Branch: refs/heads/LOG4J2-1365
Commit: 71fbda804e3d75ef77bdef57e37f5fb85267bd3e
Parents: 35d0689
Author: rpopma <rp...@apache.org>
Authored: Thu Apr 14 23:54:33 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Thu Apr 14 23:54:33 2016 +0900
----------------------------------------------------------------------
.../apache/logging/log4j/core/impl/Log4jLogEvent.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/71fbda80/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 57b0dcc..c062259 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
@@ -634,8 +634,16 @@ public Log4jLogEvent(final String loggerName, final Marker marker, final String
return new LogEventProxy(this, this.includeLocation);
}
- public static Serializable serialize(final Log4jLogEvent event,
- final boolean includeLocation) {
+ public static Serializable serialize(final LogEvent event, final boolean includeLocation) {
+ if (event instanceof Log4jLogEvent) {
+ event.getThrownProxy(); // ensure ThrowableProxy is initialized
+ return new LogEventProxy((Log4jLogEvent) event, includeLocation);
+ } else {
+ return new LogEventProxy(event, includeLocation);
+ }
+ }
+
+ public static Serializable serialize(final Log4jLogEvent event, final boolean includeLocation) {
event.getThrownProxy(); // ensure ThrowableProxy is initialized
return new LogEventProxy(event, includeLocation);
}
[3/7] logging-log4j2 git commit: LOG4J2-1334 let LogEventProxy accept
any LogEvent source
Posted by mi...@apache.org.
LOG4J2-1334 let LogEventProxy accept any LogEvent source
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/d2a79e0e
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d2a79e0e
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d2a79e0e
Branch: refs/heads/LOG4J2-1365
Commit: d2a79e0e6e655774129dfc71632de42518b4475d
Parents: aaaaaad
Author: rpopma <rp...@apache.org>
Authored: Thu Apr 14 23:49:23 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Thu Apr 14 23:49:23 2016 +0900
----------------------------------------------------------------------
.../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/d2a79e0e/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 2e017dd..57b0dcc 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
@@ -812,7 +812,7 @@ public Log4jLogEvent(final String loggerName, final Marker marker, final String
this.nanoTime = event.nanoTime;
}
- public LogEventProxy(final MutableLogEvent event, final boolean includeLocation) {
+ public LogEventProxy(final LogEvent event, final boolean includeLocation) {
this.loggerFQCN = event.getLoggerFqcn();
this.marker = event.getMarker();
this.level = event.getLevel();
[7/7] logging-log4j2 git commit: Remove CharSequenceFormattable from
ParameterizedMessages
Posted by mi...@apache.org.
Remove CharSequenceFormattable from ParameterizedMessages
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/299f488d
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/299f488d
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/299f488d
Branch: refs/heads/LOG4J2-1365
Commit: 299f488dceb9035892e5f4a3d68cf5c1a801dcee
Parents: 0ec82b7
Author: Mikael Ståldal <mi...@magine.com>
Authored: Fri Apr 15 14:48:07 2016 +0200
Committer: Mikael Ståldal <mi...@magine.com>
Committed: Fri Apr 15 14:48:07 2016 +0200
----------------------------------------------------------------------
.../logging/log4j/message/ParameterizedMessage.java | 14 +-------------
.../log4j/message/ReusableParameterizedMessage.java | 10 +---------
2 files changed, 2 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/299f488d/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
index 4e8648e..1747102 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java
@@ -16,7 +16,6 @@
*/
package org.apache.logging.log4j.message;
-import org.apache.logging.log4j.util.CharSequenceFormattable;
import org.apache.logging.log4j.util.StringBuilderFormattable;
import java.util.Arrays;
@@ -29,7 +28,7 @@ import java.util.Arrays;
* licensed under the LGPL. It has been relicensed here with his permission providing that this attribution remain.
* </p>
*/
-public class ParameterizedMessage implements Message, StringBuilderFormattable, CharSequenceFormattable {
+public class ParameterizedMessage implements Message, StringBuilderFormattable {
/**
* Prefix for recursion.
*/
@@ -220,17 +219,6 @@ public class ParameterizedMessage implements Message, StringBuilderFormattable,
}
}
- @Override
- public CharSequence getFormattedCharSequence() {
- if (formattedMessage != null) {
- return formattedMessage;
- } else {
- final StringBuilder buffer = getThreadLocalStringBuilder();
- formatTo(buffer);
- return buffer;
- }
- }
-
/**
* Replace placeholders in the given messagePattern with arguments.
*
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/299f488d/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 c4c15d5..22b0b15 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
@@ -16,7 +16,6 @@
*/
package org.apache.logging.log4j.message;
-import org.apache.logging.log4j.util.CharSequenceFormattable;
import org.apache.logging.log4j.util.PerformanceSensitive;
import java.util.Arrays;
@@ -29,7 +28,7 @@ import java.util.Arrays;
* @since 2.6
*/
@PerformanceSensitive("allocation")
-public class ReusableParameterizedMessage implements ReusableMessage, CharSequenceFormattable {
+public class ReusableParameterizedMessage implements ReusableMessage {
private static final long serialVersionUID = 7800075879295123856L;
private static ThreadLocal<StringBuilder> buffer = new ThreadLocal<>();
@@ -259,13 +258,6 @@ public class ReusableParameterizedMessage implements ReusableMessage, CharSequen
}
@Override
- public CharSequence getFormattedCharSequence() {
- final StringBuilder sb = getBuffer();
- formatTo(sb);
- return sb;
- }
-
- @Override
public String toString() {
return "ReusableParameterizedMessage[messagePattern=" + getFormat() + ", stringArgs=" +
Arrays.toString(getParameters()) + ", throwable=" + getThrowable() + ']';