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.State
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Constructor and Description |
---|
AsyncLoggerConfigDisruptor(AsyncWaitStrategyFactory asyncWaitStrategyFactory) |
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, stop
public AsyncLoggerConfigDisruptor(AsyncWaitStrategyFactory asyncWaitStrategyFactory)
public void setLogEventFactory(LogEventFactory logEventFactory)
AsyncLoggerConfigDelegate
setLogEventFactory
in interface AsyncLoggerConfigDelegate
logEventFactory
- the factory usedpublic void start()
start
in interface LifeCycle
start
in class AbstractLifeCycle
AbstractLifeCycle.stop()
public boolean stop(long timeout, TimeUnit timeUnit)
null
.stop
in interface LifeCycle2
stop
in class AbstractLifeCycle
timeout
- the maximum time to waittimeUnit
- the time unit of the timeout argumentpublic EventRoute getEventRoute(Level logLevel)
AsyncLoggerConfigDelegate
EventRoute
for the event with the specified level.getEventRoute
in interface AsyncLoggerConfigDelegate
logLevel
- the level of the event to logEventRoute
public void enqueueEvent(LogEvent event, AsyncLoggerConfig asyncLoggerConfig)
AsyncLoggerConfigDelegate
LogEvent
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 AsyncLoggerConfigDelegate
public boolean tryEnqueue(LogEvent event, AsyncLoggerConfig asyncLoggerConfig)
tryEnqueue
in interface AsyncLoggerConfigDelegate
public RingBufferAdmin createRingBufferAdmin(String contextName, String loggerConfigName)
AsyncLoggerConfigDelegate
RingBufferAdmin
that instruments the ringbuffer of this
AsyncLoggerConfig
.createRingBufferAdmin
in interface AsyncLoggerConfigDelegate
contextName
- name of the LoggerContext
loggerConfigName
- name of the logger config 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.