Search in sources :

Example 1 with NoOpThreadContextMap

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

the class ThreadContext method init.

/**
 * <em>Consider private, used for testing.</em>
 */
static void init() {
    ThreadContextMapFactory.init();
    contextMap = null;
    final PropertiesUtil managerProps = PropertiesUtil.getProperties();
    final boolean disableAll = managerProps.getBooleanProperty(DISABLE_ALL);
    useStack = !(managerProps.getBooleanProperty(DISABLE_STACK) || disableAll);
    final boolean 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;
    } else {
        readOnlyContextMap = null;
    }
}
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