public class AsyncLoggerConfigDisruptor extends AbstractLifeCycle implements AsyncLoggerConfigDelegate
AsyncLoggerConfig class from the LMAX Disruptor library.
AsyncLoggerConfig is a plugin, and will be loaded even if users do not configure any <asyncLogger> or
<asyncRoot> elements in the configuration. If AsyncLoggerConfig has inner classes that extend or
implement classes from the Disruptor library, a NoClassDefFoundError is thrown if the Disruptor jar is not in
the classpath when the PluginManager loads the AsyncLoggerConfig plugin from the pre-defined plugins
definition file.
This class serves to make the dependency on the Disruptor optional, so that these classes are only loaded when the
AsyncLoggerConfig is actually used.
| Modifier and Type | Class and Description |
|---|---|
static class |
AsyncLoggerConfigDisruptor.Log4jEventWrapper
RingBuffer events contain all information necessary to perform the work in a separate thread.
|
LifeCycle.StateDEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER| Constructor and Description |
|---|
AsyncLoggerConfigDisruptor() |
| Modifier and Type | Method and Description |
|---|---|
RingBufferAdmin |
createRingBufferAdmin(String contextName,
String loggerConfigName)
Creates and returns a new
RingBufferAdmin that instruments the ringbuffer of this
AsyncLoggerConfig. |
void |
enqueueEvent(LogEvent event,
AsyncLoggerConfig asyncLoggerConfig)
Enqueues the
LogEvent on the mixed configuration ringbuffer. |
EventRoute |
getEventRoute(Level logLevel)
Returns the
EventRoute for the event with the specified level. |
void |
setLogEventFactory(LogEventFactory logEventFactory)
Notifies the delegate what LogEventFactory an AsyncLoggerConfig is using, so the delegate can determine
whether to populate the ring buffer with mutable log events or not.
|
void |
start()
Increases the reference count and creates and starts a new Disruptor and associated thread if none currently
exists.
|
boolean |
stop(long timeout,
TimeUnit timeUnit)
Decreases the reference count.
|
boolean |
tryEnqueue(LogEvent event,
AsyncLoggerConfig asyncLoggerConfig) |
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stoppublic void setLogEventFactory(LogEventFactory logEventFactory)
AsyncLoggerConfigDelegatesetLogEventFactory in interface AsyncLoggerConfigDelegatelogEventFactory - the factory usedpublic void start()
start in interface LifeCyclestart in class AbstractLifeCycleAbstractLifeCycle.stop()public boolean stop(long timeout,
TimeUnit timeUnit)
null.stop in interface LifeCycle2stop in class AbstractLifeCycletimeout - the maximum time to waittimeUnit - the time unit of the timeout argumentpublic EventRoute getEventRoute(Level logLevel)
AsyncLoggerConfigDelegateEventRoute for the event with the specified level.getEventRoute in interface AsyncLoggerConfigDelegatelogLevel - the level of the event to logEventRoutepublic void enqueueEvent(LogEvent event, AsyncLoggerConfig asyncLoggerConfig)
AsyncLoggerConfigDelegateLogEvent on the mixed configuration ringbuffer.
This method must only be used after AsyncLoggerConfigDelegate.tryEnqueue(LogEvent, AsyncLoggerConfig) returns false
indicating that the ringbuffer is full, otherwise it may incur unnecessary synchronization.enqueueEvent in interface AsyncLoggerConfigDelegatepublic boolean tryEnqueue(LogEvent event, AsyncLoggerConfig asyncLoggerConfig)
tryEnqueue in interface AsyncLoggerConfigDelegatepublic RingBufferAdmin createRingBufferAdmin(String contextName, String loggerConfigName)
AsyncLoggerConfigDelegateRingBufferAdmin that instruments the ringbuffer of this
AsyncLoggerConfig.createRingBufferAdmin in interface AsyncLoggerConfigDelegatecontextName - name of the LoggerContextloggerConfigName - name of the logger configCopyright © 1999-2021 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.