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
FieldsFields inherited from class org.apache.logging.log4j.core.LoggerContext
PROPERTY_CONFIGFields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGERFields inherited from interface org.apache.logging.log4j.spi.LoggerContext
EMPTY_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionAsyncLoggerContext(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 newRingBufferAdminthat instruments the ringbuffer of theAsyncLoggerobjects in thisLoggerContext.private voidmaybeStartHelper(Configuration config) protected LoggernewInstance(LoggerContext ctx, String name, MessageFactory messageFactory) voidSets the name.voidsetUseThreadLocals(boolean useThreadLocals) Signals this context whether it is allowed to use ThreadLocal objects for efficiency.voidstart()voidstart(Configuration config) Starts with a specific configuration.booleanBlocks 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, updateLoggersMethods 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, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.logging.log4j.spi.LoggerContext
getLogger, getLogger
-
Field Details
-
loggerDisruptor
-
-
Constructor Details
-
AsyncLoggerContext
-
AsyncLoggerContext
-
AsyncLoggerContext
-
AsyncLoggerContext
-
-
Method Details
-
newInstance
- Overrides:
newInstancein classLoggerContext
-
setName
Description copied from class:LoggerContextSets the name.- Overrides:
setNamein classLoggerContext- Parameters:
name- the new LoggerContext name
-
start
public void start()- Specified by:
startin interfaceLifeCycle- Overrides:
startin classLoggerContext
-
start
Description copied from class:LoggerContextStarts with a specific configuration.- Overrides:
startin classLoggerContext- Parameters:
config- The new Configuration.
-
maybeStartHelper
-
stop
Description copied from class:LoggerContextBlocks 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:
stopin interfaceLifeCycle2- Overrides:
stopin 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:
trueif the logger context terminated andfalseif the timeout elapsed before termination.
-
createRingBufferAdmin
Creates and returns a newRingBufferAdminthat instruments the ringbuffer of theAsyncLoggerobjects in thisLoggerContext.- Returns:
- a new
RingBufferAdminthat 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
-