Package net.logstash.logback.appender
Class DelegatingAsyncDisruptorAppender<Event extends DeferredProcessingAware,Listener extends AppenderListener<Event>>
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.UnsynchronizedAppenderBase<Event>
net.logstash.logback.appender.AsyncDisruptorAppender<Event,Listener>
net.logstash.logback.appender.DelegatingAsyncDisruptorAppender<Event,Listener>
- Type Parameters:
Event
- type of event (ILoggingEvent
orIAccessEvent
).
- All Implemented Interfaces:
Appender<Event>
,AppenderAttachable<Event>
,ContextAware
,FilterAttachable<Event>
,LifeCycle
- Direct Known Subclasses:
AccessEventAsyncDisruptorAppender
,LoggingEventAsyncDisruptorAppender
public abstract class DelegatingAsyncDisruptorAppender<Event extends DeferredProcessingAware,Listener extends AppenderListener<Event>>
extends AsyncDisruptorAppender<Event,Listener>
implements AppenderAttachable<Event>
An
AsyncDisruptorAppender
that delegates appending of an event
to delegate appenders
.
This is very similar to logback's AsyncAppenderBase
, except that:
- it uses a
RingBuffer
instead of aBlockingQueue
- it allows any number of delegate appenders, instead of just one
- it flushes appenders of type
OutputStreamAppender
orFlushable
at the end of a batch - it is resilient to exceptions and guarantees that all appenders are invoked
-
Nested Class Summary
Nested classes/interfaces inherited from class net.logstash.logback.appender.AsyncDisruptorAppender
AsyncDisruptorAppender.LogEvent<Event>, AsyncDisruptorAppender.LogEventFactory<Event>, AsyncDisruptorAppender.LogEventTranslator<Event>
-
Field Summary
Fields inherited from class net.logstash.logback.appender.AsyncDisruptorAppender
APPENDER_NAME_FORMAT, DEFAULT_DROPPED_WARN_FREQUENCY, DEFAULT_PRODUCER_TYPE, DEFAULT_RING_BUFFER_SIZE, DEFAULT_THREAD_NAME_FORMAT, DEFAULT_WAIT_STRATEGY, listeners, THREAD_INDEX_FORMAT
Fields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
name, started
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAppender
(Appender<Event> newAppender) protected com.lmax.disruptor.EventHandler<AsyncDisruptorAppender.LogEvent<Event>>
Create theEventHandler
to process events as they become available from the RingBuffer.void
boolean
detachAppender
(Appender<Event> appender) boolean
detachAppender
(String name) getAppender
(String name) boolean
isAttached
(Appender<Event> appender) void
start()
void
stop()
Methods inherited from class net.logstash.logback.appender.AsyncDisruptorAppender
addListener, append, calculateThreadName, fireAppenderStarted, fireAppenderStopped, fireEventAppended, fireEventAppendFailed, getAppendRetryFrequency, getAppendTimeout, getDisruptor, getDroppedWarnFrequency, getEventTranslator, getProducerType, getRingBufferSize, getShutdownGracePeriod, getThreadFactory, getThreadNameFormat, getThreadNameFormatParams, getWaitStrategy, isAddDefaultStatusListener, isDaemon, isRingBufferEmpty, prepareForDeferredProcessing, removeListener, safelyFireEvent, setAddDefaultStatusListener, setAppendRetryFrequency, setAppendTimeout, setDaemon, setDroppedWarnFrequency, setEventFactory, setEventTranslator, setProducerType, setRingBufferSize, setShutdownGracePeriod, setThreadFactory, setThreadNameFormat, setWaitStrategy, setWaitStrategyType
Methods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, toString
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Constructor Details
-
DelegatingAsyncDisruptorAppender
public DelegatingAsyncDisruptorAppender()
-
-
Method Details
-
createEventHandler
protected com.lmax.disruptor.EventHandler<AsyncDisruptorAppender.LogEvent<Event>> createEventHandler()Description copied from class:AsyncDisruptorAppender
Create theEventHandler
to process events as they become available from the RingBuffer. This method is invoked when the appender is started byAsyncDisruptorAppender.start()
and a newDisruptor
is initialized.- Specified by:
createEventHandler
in classAsyncDisruptorAppender<Event extends DeferredProcessingAware,
Listener extends AppenderListener<Event>> - Returns:
- a
EventHandler
instance.
-
start
public void start()- Specified by:
start
in interfaceLifeCycle
- Overrides:
start
in classAsyncDisruptorAppender<Event extends DeferredProcessingAware,
Listener extends AppenderListener<Event>>
-
stop
public void stop()- Specified by:
stop
in interfaceLifeCycle
- Overrides:
stop
in classAsyncDisruptorAppender<Event extends DeferredProcessingAware,
Listener extends AppenderListener<Event>>
-
addAppender
- Specified by:
addAppender
in interfaceAppenderAttachable<Event extends DeferredProcessingAware>
-
iteratorForAppenders
- Specified by:
iteratorForAppenders
in interfaceAppenderAttachable<Event extends DeferredProcessingAware>
-
getAppender
- Specified by:
getAppender
in interfaceAppenderAttachable<Event extends DeferredProcessingAware>
-
isAttached
- Specified by:
isAttached
in interfaceAppenderAttachable<Event extends DeferredProcessingAware>
-
detachAndStopAllAppenders
public void detachAndStopAllAppenders()- Specified by:
detachAndStopAllAppenders
in interfaceAppenderAttachable<Event extends DeferredProcessingAware>
-
detachAppender
- Specified by:
detachAppender
in interfaceAppenderAttachable<Event extends DeferredProcessingAware>
-
detachAppender
- Specified by:
detachAppender
in interfaceAppenderAttachable<Event extends DeferredProcessingAware>
-