public static class ThreadContextDataInjector.ForDefaultThreadContextMap extends Object implements ContextDataInjector
ContextDataInjector
for the legacy Map<String, String>
-based ThreadContext (which is
also the ThreadContext implementation used for web applications).
This injector always puts key-value pairs into the specified reusable StringMap.
Constructor and Description |
---|
ForDefaultThreadContextMap() |
Modifier and Type | Method and Description |
---|---|
org.apache.logging.log4j.util.StringMap |
injectContextData(List<Property> props,
org.apache.logging.log4j.util.StringMap contextData)
Puts key-value pairs from both the specified list of properties as well as the thread context into the
specified reusable StringMap.
|
org.apache.logging.log4j.util.ReadOnlyStringMap |
rawContextData()
Returns a
ReadOnlyStringMap object reflecting the current state of the context. |
public ForDefaultThreadContextMap()
public org.apache.logging.log4j.util.StringMap injectContextData(List<Property> props, org.apache.logging.log4j.util.StringMap contextData)
injectContextData
in interface ContextDataInjector
props
- list of configuration properties, may be null
contextData
- a StringMap
instance from the log eventStringMap
combining configuration properties with thread context dataThreadContextDataInjector.copyProperties(List, StringMap)
public org.apache.logging.log4j.util.ReadOnlyStringMap rawContextData()
ContextDataInjector
ReadOnlyStringMap
object reflecting the current state of the context. Configuration properties
are not included in the result.
This method may be called multiple times for each log event by Filters and Lookups and implementors should take care to make this method as performant as possible while preserving at least the following thread-safety guarantee.
Thread-safety note: The returned object can only be safely used in the current thread. Changes in the underlying context may or may not be reflected in the returned object, depending on the context data source and the implementation of this method. It is not safe to pass the returned object to another thread.
rawContextData
in interface ContextDataInjector
ReadOnlyStringMap
object reflecting the current state of the context, may not return null
Copyright © 1999-2021 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.