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.
ThreadContextMap, ReadOnlyThreadContextMap, org.apache.logging.log4j.ThreadContext
| Modifier and Type | Field 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 |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static ThreadContextMap | |
| public static ThreadContextMap | |
| public static void | |
| private static void |
| COPY_ON_WRITE_CONTEXT_MAP | back to summary |
|---|---|
| private static final String COPY_ON_WRITE_CONTEXT_MAP | |
| GARBAGE_FREE_CONTEXT_MAP | back to summary |
|---|---|
| private static final String GARBAGE_FREE_CONTEXT_MAP | |
| GC_FREE_THREAD_CONTEXT_KEY | back to summary |
|---|---|
| private static final String GC_FREE_THREAD_CONTEXT_KEY | |
| GcFreeThreadContextKey | back to summary |
|---|---|
| private static boolean GcFreeThreadContextKey | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| THREAD_CONTEXT_KEY | back to summary |
|---|---|
| private static final String THREAD_CONTEXT_KEY | |
| ThreadContextMapName | back to summary |
|---|---|
| private static String ThreadContextMapName | |
| ThreadContextMapFactory | back to summary |
|---|---|
| private ThreadContextMapFactory() | |
| createDefaultThreadContextMap | back to summary |
|---|---|
| private static ThreadContextMap createDefaultThreadContextMap() | |
| createThreadContextMap | back to summary |
|---|---|
| public static ThreadContextMap createThreadContextMap() | |
| init | back 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. | |
| initPrivate | back 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. | |