- java.lang.Object
-
- org.apache.logging.log4j.spi.LoggingSystem
-
public class LoggingSystem extends Object
Handles initializing the Log4j API throughProvider
discovery. This keeps track of whichLoggerContextFactory
to use inLogManager
along with factories forThreadContextMap
andThreadContextStack
to use inThreadContext
.- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static int
THREAD_CONTEXT_DEFAULT_INITIAL_CAPACITY
-
Constructor Summary
Constructors Constructor Description LoggingSystem()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acquireInitializationLock()
Acquires a lock on the initialization of locating a logging system provider.static ThreadContextMap
createContextMap()
Creates a new ThreadContextMap.static ThreadContextStack
createContextStack()
Creates a new ThreadContextStack.static FlowMessageFactory
getFlowMessageFactory()
static LoggingSystem
getInstance()
Gets the LoggingSystem instance.static LoggerContextFactory
getLoggerContextFactory()
Gets the current LoggerContextFactory.static MessageFactory
getMessageFactory()
void
releaseInitializationLock()
Releases a lock on the initialization phase of this logging system.void
setFlowMessageFactory(FlowMessageFactory flowMessageFactory)
void
setLoggerContextFactory(LoggerContextFactory loggerContextFactory)
void
setMessageFactory(MessageFactory messageFactory)
void
setThreadContextMapFactory(Supplier<ThreadContextMap> threadContextMapFactory)
void
setThreadContextStackFactory(Supplier<ThreadContextStack> threadContextStackFactory)
-
-
-
Field Detail
-
THREAD_CONTEXT_DEFAULT_INITIAL_CAPACITY
public static final int THREAD_CONTEXT_DEFAULT_INITIAL_CAPACITY
- See Also:
- Constant Field Values
-
-
Method Detail
-
acquireInitializationLock
@InternalApi public void acquireInitializationLock()
Acquires a lock on the initialization of locating a logging system provider. This lock should be released once the logging system provider is loaded. This lock is provided to allow for lazy initialization via frameworks like OSGi to wait for a provider to be installed before allowing initialization to continue.- See Also:
- LOG4J2-373
-
releaseInitializationLock
@InternalApi public void releaseInitializationLock()
Releases a lock on the initialization phase of this logging system.
-
setLoggerContextFactory
public void setLoggerContextFactory(LoggerContextFactory loggerContextFactory)
-
setMessageFactory
public void setMessageFactory(MessageFactory messageFactory)
-
setFlowMessageFactory
public void setFlowMessageFactory(FlowMessageFactory flowMessageFactory)
-
setThreadContextMapFactory
public void setThreadContextMapFactory(Supplier<ThreadContextMap> threadContextMapFactory)
-
setThreadContextStackFactory
public void setThreadContextStackFactory(Supplier<ThreadContextStack> threadContextStackFactory)
-
getInstance
public static LoggingSystem getInstance()
Gets the LoggingSystem instance.
-
getLoggerContextFactory
public static LoggerContextFactory getLoggerContextFactory()
Gets the current LoggerContextFactory. This may initialize the instance if this is the first time it was requested.
-
getMessageFactory
public static MessageFactory getMessageFactory()
-
getFlowMessageFactory
public static FlowMessageFactory getFlowMessageFactory()
-
createContextMap
public static ThreadContextMap createContextMap()
Creates a new ThreadContextMap.
-
createContextStack
public static ThreadContextStack createContextStack()
Creates a new ThreadContextStack.
-
-