public class AsyncLoggerConfigDisruptor extends Object 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.
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 |
start()
Increases the reference count and creates and starts a new Disruptor and associated thread if none currently
exists.
|
void |
stop()
Decreases the reference count.
|
boolean |
tryCallAppendersInBackground(LogEvent event,
AsyncLoggerConfig asyncLoggerConfig)
If possible, delegates the invocation of
callAppenders to the background thread and returns true . |
public void start()
#release()
public void stop()
null
.public boolean tryCallAppendersInBackground(LogEvent event, AsyncLoggerConfig asyncLoggerConfig)
AsyncLoggerConfigDelegate
callAppenders
to the background thread and returns true
.
If this is not possible (if it detects that delegating to the background thread would cause deadlock because the
current call to Logger.log() originated from the background thread and the ringbuffer is full) then this method
does nothing and returns false
. It is the responsibility of the caller to process the event when this
method returns false
.tryCallAppendersInBackground
in interface AsyncLoggerConfigDelegate
event
- the event to delegate to the background threadasyncLoggerConfig
- the logger config to call from the background threadtrue
if delegation was successful, false
if the calling thread needs to process the event
itselfpublic 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 configCopyright © 1999-2017 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.