Package org.apache.logging.log4j.spi
Class ThreadContextMapFactory
- java.lang.Object
-
- org.apache.logging.log4j.spi.ThreadContextMapFactory
-
public final class ThreadContextMapFactory extends java.lang.ObjectCreates 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 propertylog4j2.garbagefree.threadContextMaptotrue.Furthermore, any custom
ThreadContextMapcan be installed by setting system propertylog4j2.threadContextMapto the fully qualified class name of the class implementing theThreadContextMapinterface. (Also implement theReadOnlyThreadContextMapinterface if your customThreadContextMapimplementation should be accessible to applications via theThreadContext.getThreadContextMap()method.)Instead of system properties, the above can also be specified in a properties file named
log4j2.component.propertiesin the classpath.- Since:
- 2.7
- See Also:
ThreadContextMap,ReadOnlyThreadContextMap,ThreadContext
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringGC_FREE_THREAD_CONTEXT_KEYprivate static booleanGcFreeThreadContextKeyprivate static LoggerLOGGERprivate static java.lang.StringTHREAD_CONTEXT_KEYprivate static java.lang.StringThreadContextMapName
-
Constructor Summary
Constructors Modifier Constructor Description privateThreadContextMapFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static ThreadContextMapcreateDefaultThreadContextMap()static ThreadContextMapcreateThreadContextMap()static voidinit()Initializes static variables based on system properties.private static voidinitPrivate()Initializes static variables based on system properties.
-
-
-
Field Detail
-
LOGGER
private static final Logger LOGGER
-
THREAD_CONTEXT_KEY
private static final java.lang.String THREAD_CONTEXT_KEY
- See Also:
- Constant Field Values
-
GC_FREE_THREAD_CONTEXT_KEY
private static final java.lang.String GC_FREE_THREAD_CONTEXT_KEY
- See Also:
- Constant Field Values
-
GcFreeThreadContextKey
private static boolean GcFreeThreadContextKey
-
ThreadContextMapName
private static java.lang.String ThreadContextMapName
-
-
Method Detail
-
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
public static ThreadContextMap createThreadContextMap()
-
createDefaultThreadContextMap
private static ThreadContextMap createDefaultThreadContextMap()
-
-