Top Description Fields Constructors Methods
org.apache.logging.log4j.spi

public final Class ThreadContextMapFactory

extends Object
Class Inheritance
Imports
org.apache.logging.log4j.LogManager, .Logger, .ThreadContext, org.apache.logging.log4j.status.StatusLogger, org.apache.logging.log4j.util.Constants, .LoaderUtil, .PropertiesUtil, .ProviderUtil

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
ThreadContextMap, ReadOnlyThreadContextMap, org.apache.logging.log4j.ThreadContext

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String
private static boolean
private static final Logger
private static final String
private static String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static ThreadContextMap
public static ThreadContextMap
public static void
init()

Initializes static variables based on system properties.

private static void
initPrivate()

Initializes static variables based on system properties.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COPY_ON_WRITE_CONTEXT_MAPback to summary
private static final String COPY_ON_WRITE_CONTEXT_MAP
GARBAGE_FREE_CONTEXT_MAPback to summary
private static final String GARBAGE_FREE_CONTEXT_MAP
GC_FREE_THREAD_CONTEXT_KEYback to summary
private static final String GC_FREE_THREAD_CONTEXT_KEY
GcFreeThreadContextKeyback to summary
private static boolean GcFreeThreadContextKey
LOGGERback to summary
private static final Logger LOGGER
THREAD_CONTEXT_KEYback to summary
private static final String THREAD_CONTEXT_KEY
ThreadContextMapNameback to summary
private static String ThreadContextMapName

Constructor Detail

ThreadContextMapFactoryback to summary
private ThreadContextMapFactory()

Method Detail

createDefaultThreadContextMapback to summary
private static ThreadContextMap createDefaultThreadContextMap()
createThreadContextMapback to summary
public static ThreadContextMap createThreadContextMap()
initback to summary
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.

initPrivateback to summary
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.