Package org.apache.logging.log4j.spi
Class ThreadContextMapFactory
java.lang.Object
org.apache.logging.log4j.spi.ThreadContextMapFactory
Creates the ThreadContextMap instance used by the ThreadContext.
If Log4j can use ThreadLocals, a garbage-free StringMap-based context map can
be installed by setting system property log4j2.garbagefree.threadContextMap to true.
Furthermore, any custom ThreadContextMap can be installed by setting system property
log4j2.threadContextMap to the fully qualified class name of the class implementing the
ThreadContextMap interface. (Also implement the ReadOnlyThreadContextMap interface if your custom
ThreadContextMap implementation should be accessible to applications via the
ThreadContext.getThreadContextMap() method.)
Instead of system properties, the above can also be specified in a properties file named
log4j2.component.properties in the classpath.
- Since:
- 2.7
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static ThreadContextMapstatic ThreadContextMapstatic voidinit()Initializes static variables based on system properties.private static voidInitializes static variables based on system properties.
-
Field Details
-
LOGGER
-
THREAD_CONTEXT_KEY
- See Also:
-
GC_FREE_THREAD_CONTEXT_KEY
- See Also:
-
GcFreeThreadContextKey
private static boolean GcFreeThreadContextKey -
ThreadContextMapName
-
-
Constructor Details
-
ThreadContextMapFactory
private ThreadContextMapFactory()
-
-
Method Details
-
init
public static void init()Initializes static variables based on system properties. Normally called when this class is initialized by the VM and when Log4j is reconfigured. -
initPrivate
private static void initPrivate()Initializes static variables based on system properties. Normally called when this class is initialized by the VM and when Log4j is reconfigured. -
createThreadContextMap
-
createDefaultThreadContextMap
-