public class AsyncLoggerContext extends LoggerContext
LoggerContext
that creates AsyncLogger
objects.LifeCycle.State
PROPERTY_CONFIG
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
EMPTY_ARRAY
Constructor and Description |
---|
AsyncLoggerContext(String name) |
AsyncLoggerContext(String name,
Object externalContext) |
AsyncLoggerContext(String name,
Object externalContext,
String configLocn) |
AsyncLoggerContext(String name,
Object externalContext,
URI configLocn) |
Modifier and Type | Method and Description |
---|---|
RingBufferAdmin |
createRingBufferAdmin()
Creates and returns a new
RingBufferAdmin that instruments the ringbuffer of the AsyncLogger
objects in this LoggerContext . |
protected Logger |
newInstance(LoggerContext ctx,
String name,
MessageFactory messageFactory) |
void |
setName(String name)
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 |
stop(long timeout,
TimeUnit timeUnit)
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.
|
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
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLogger, getLogger
public AsyncLoggerContext(String name)
protected Logger newInstance(LoggerContext ctx, String name, MessageFactory messageFactory)
newInstance
in class LoggerContext
public void setName(String name)
LoggerContext
setName
in class LoggerContext
name
- the new LoggerContext namepublic void start()
start
in interface LifeCycle
start
in class LoggerContext
public void start(Configuration config)
LoggerContext
start
in class LoggerContext
config
- The new Configuration.public boolean stop(long timeout, TimeUnit timeUnit)
LoggerContext
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.
stop
in interface LifeCycle2
stop
in class LoggerContext
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 argumenttrue
if the logger context terminated and false
if the timeout elapsed before
termination.public RingBufferAdmin createRingBufferAdmin()
RingBufferAdmin
that instruments the ringbuffer of the AsyncLogger
objects in this LoggerContext
.RingBufferAdmin
that instruments the ringbufferpublic void setUseThreadLocals(boolean useThreadLocals)
useThreadLocals
- whether this context is allowed to use ThreadLocal objects Copyright © 1999-2023 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.