Package org.apache.logging.log4j.spi
Class ThreadContextMapFactory
- java.lang.Object
-
- org.apache.logging.log4j.spi.ThreadContextMapFactory
-
public final class ThreadContextMapFactory extends java.lang.Object
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 propertylog4j2.garbagefree.threadContextMap
totrue
.Furthermore, any custom
ThreadContextMap
can be installed by setting system propertylog4j2.threadContextMap
to the fully qualified class name of the class implementing theThreadContextMap
interface. (Also implement theReadOnlyThreadContextMap
interface if your customThreadContextMap
implementation 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.properties
in the classpath.- Since:
- 2.7
- See Also:
ThreadContextMap
,ReadOnlyThreadContextMap
,ThreadContext
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ThreadContextMap
createThreadContextMap()
static void
init()
Initializes static variables based on system properties.
-
-
-
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.
-
createThreadContextMap
public static ThreadContextMap createThreadContextMap()
-
-