LOG4J2-1447 inject ContextData every time a MutableLogEvent is initialized
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2a18e9b8 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2a18e9b8 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2a18e9b8 Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure Commit: 2a18e9b8a612483238eaf05822e2a344c6ada669 Parents: 6caf1e8 Author: rpopma <[email protected]> Authored: Wed Jul 27 01:18:29 2016 +0900 Committer: rpopma <[email protected]> Committed: Wed Jul 27 01:18:29 2016 +0900 ---------------------------------------------------------------------- .../apache/logging/log4j/core/impl/ReusableLogEventFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2a18e9b8/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactory.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactory.java index f396a4c..ebfdd1c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactory.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactory.java @@ -38,6 +38,8 @@ public class ReusableLogEventFactory implements LogEventFactory { private static final Clock CLOCK = ClockFactory.getClock(); private static ThreadLocal<MutableLogEvent> mutableLogEventThreadLocal = new ThreadLocal<>(); + private final ContextDataInjector injector = ContextDataInjectorFactory.getInjector(); + /** * Creates a log event. * @@ -72,7 +74,7 @@ public class ReusableLogEventFactory implements LogEventFactory { result.setLevel(level == null ? Level.OFF : level); result.setMessage(message); result.setThrown(t); - result.setContextMap(Log4jLogEvent.createMap(properties)); + injector.injectContextData(properties, (MutableContextData) result.getContextData()); result.setContextStack(ThreadContext.getDepth() == 0 ? null : ThreadContext.cloneStack());// mutable copy result.setTimeMillis(message instanceof TimestampMessage ? ((TimestampMessage) message).getTimestamp()
