Search in sources :

Example 1 with ReadOnlyThreadContextMap

use of org.apache.logging.log4j.spi.ReadOnlyThreadContextMap in project logging-log4j2 by apache.

the class ThreadContext method init.

/**
     * <em>Consider private, used for testing.</em>
     */
static void init() {
    contextMap = null;
    final PropertiesUtil managerProps = PropertiesUtil.getProperties();
    disableAll = managerProps.getBooleanProperty(DISABLE_ALL);
    useStack = !(managerProps.getBooleanProperty(DISABLE_STACK) || disableAll);
    useMap = !(managerProps.getBooleanProperty(DISABLE_MAP) || disableAll);
    contextStack = new DefaultThreadContextStack(useStack);
    if (!useMap) {
        contextMap = new NoOpThreadContextMap();
    } else {
        contextMap = ThreadContextMapFactory.createThreadContextMap();
    }
    if (contextMap instanceof ReadOnlyThreadContextMap) {
        readOnlyContextMap = (ReadOnlyThreadContextMap) contextMap;
    }
}
Also used : DefaultThreadContextStack(org.apache.logging.log4j.spi.DefaultThreadContextStack) PropertiesUtil(org.apache.logging.log4j.util.PropertiesUtil) NoOpThreadContextMap(org.apache.logging.log4j.spi.NoOpThreadContextMap) ReadOnlyThreadContextMap(org.apache.logging.log4j.spi.ReadOnlyThreadContextMap)

Aggregations

DefaultThreadContextStack (org.apache.logging.log4j.spi.DefaultThreadContextStack)1 NoOpThreadContextMap (org.apache.logging.log4j.spi.NoOpThreadContextMap)1 ReadOnlyThreadContextMap (org.apache.logging.log4j.spi.ReadOnlyThreadContextMap)1 PropertiesUtil (org.apache.logging.log4j.util.PropertiesUtil)1