Class AsyncLoggerContext
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.LoggerContext
org.apache.logging.log4j.core.async.AsyncLoggerContext
- All Implemented Interfaces:
AutoCloseable
,ConfigurationListener
,LifeCycle
,LifeCycle2
,LoggerContext
,LoggerContextShutdownEnabled
,Terminable
LoggerContext
that creates AsyncLogger
objects.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
Field Summary
Fields inherited from class org.apache.logging.log4j.core.LoggerContext
PROPERTY_CONFIG
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Fields inherited from interface org.apache.logging.log4j.spi.LoggerContext
EMPTY_ARRAY
-
Constructor Summary
ConstructorDescriptionAsyncLoggerContext
(String name) AsyncLoggerContext
(String name, Object externalContext) AsyncLoggerContext
(String name, Object externalContext, String configLocn) AsyncLoggerContext
(String name, Object externalContext, URI configLocn) -
Method Summary
Modifier and TypeMethodDescriptionCreates and returns a newRingBufferAdmin
that instruments the ringbuffer of theAsyncLogger
objects in thisLoggerContext
.protected Logger
newInstance
(LoggerContext ctx, String name, MessageFactory messageFactory) void
Sets the name.void
setUseThreadLocals
(boolean useThreadLocals) Signals this context whether it is allowed to use ThreadLocal objects for efficiency.void
start()
void
start
(Configuration config) Starts with a specific configuration.boolean
Blocks until all Log4j tasks have completed execution after a shutdown request and all appenders have shut down, or the timeout occurs, or the current thread is interrupted, whichever happens first.Methods inherited from class org.apache.logging.log4j.core.LoggerContext
addFilter, addPropertyChangeListener, addShutdownListener, close, getConfigLocation, getConfiguration, getContext, getContext, getContext, getExternalContext, getListeners, getLogger, getLogger, getLoggerRegistry, getLoggers, getName, getObject, getRootLogger, hasLogger, hasLogger, hasLogger, onChange, putObject, putObjectIfAbsent, reconfigure, reconfigure, removeFilter, removeObject, removeObject, removePropertyChangeListener, setConfigLocation, setConfiguration, setExternalContext, terminate, updateLoggers, updateLoggers
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.logging.log4j.spi.LoggerContext
getLogger, getLogger
-
Constructor Details
-
AsyncLoggerContext
-
AsyncLoggerContext
-
AsyncLoggerContext
-
AsyncLoggerContext
-
-
Method Details
-
newInstance
- Overrides:
newInstance
in classLoggerContext
-
setName
Description copied from class:LoggerContext
Sets the name.- Overrides:
setName
in classLoggerContext
- Parameters:
name
- the new LoggerContext name
-
start
public void start()- Specified by:
start
in interfaceLifeCycle
- Overrides:
start
in classLoggerContext
-
start
Description copied from class:LoggerContext
Starts with a specific configuration.- Overrides:
start
in classLoggerContext
- Parameters:
config
- The new Configuration.
-
stop
Description copied from class:LoggerContext
Blocks until all Log4j tasks have completed execution after a shutdown request and all appenders have shut down, or the timeout occurs, or the current thread is interrupted, whichever happens first.Not all appenders will honor this, it is a hint and not an absolute guarantee that the this method not block longer. Setting timeout too low increase the risk of losing outstanding log events not yet written to the final destination.
Log4j can start threads to perform certain actions like file rollovers, calling this method with a positive timeout will block until the rollover thread is done.
- Specified by:
stop
in interfaceLifeCycle2
- Overrides:
stop
in classLoggerContext
- Parameters:
timeout
- the maximum time to wait, or 0 which mean that each apppender uses its default timeout, and don't wait for background taskstimeUnit
- the time unit of the timeout argument- Returns:
true
if the logger context terminated andfalse
if the timeout elapsed before termination.
-
createRingBufferAdmin
Creates and returns a newRingBufferAdmin
that instruments the ringbuffer of theAsyncLogger
objects in thisLoggerContext
.- Returns:
- a new
RingBufferAdmin
that instruments the ringbuffer
-
setUseThreadLocals
public void setUseThreadLocals(boolean useThreadLocals) Signals this context whether it is allowed to use ThreadLocal objects for efficiency.- Parameters:
useThreadLocals
- whether this context is allowed to use ThreadLocal objects
-