Class AsyncBufferFullFallbackAppender
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.UnsynchronizedAppenderBase<E>
ch.qos.logback.core.AsyncAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
ch.admin.bag.covidcertificate.log.async.AsyncBufferFullFallbackAppender
- All Implemented Interfaces:
ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.ContextAware,ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.LifeCycle
public class AsyncBufferFullFallbackAppender
extends ch.qos.logback.core.AsyncAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
Async appender with a reference to a fallback appender to use if the async logging event buffer is nearing capacity.
Compared to the
AsyncAppender from logback, the AsyncBufferFullFallbackAppender
will spill over log events to the fallback instead of blocking or discarding log events in case the buffer is nearly full.
The fallback is used if less than fallbackThreshold (default: 20%) of the buffer size is available.
Typical use case: Spill over log events to a faster appender if the appender logged to by the async appender cannot keep up with the amount of logged events.
The fallback appender can be disabled using setUseFallbackAppender(boolean), which is useful to allow for
configuratively disabling the fallback mechanism via a property. In this case the appender behaves just like the
AsyncAppender from logback.
-
Field Summary
Fields inherited from class ch.qos.logback.core.AsyncAppenderBase
DEFAULT_MAX_FLUSH_TIME, DEFAULT_QUEUE_SIZEFields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
name, startedFields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
Constructors Constructor Description AsyncBufferFullFallbackAppender() -
Method Summary
Modifier and Type Method Description protected voidappend(ch.qos.logback.classic.spi.ILoggingEvent eventObject)Append a log event asynchronously, falling back to the fallback appender ifgetRemainingCapacity() <= fallbackThresholdprotected voidpreprocess(ch.qos.logback.classic.spi.ILoggingEvent eventObject)voidsetFallback(FallbackAppenderRef fallback)voidsetFallbackThreshold(int fallbackThreshold)voidsetUseFallbackAppender(boolean useFallbackAppender)voidstart()voidstop()Methods inherited from class ch.qos.logback.core.AsyncAppenderBase
addAppender, detachAndStopAllAppenders, detachAppender, detachAppender, getAppender, getDiscardingThreshold, getMaxFlushTime, getNumberOfElementsInQueue, getQueueSize, getRemainingCapacity, isAttached, isDiscardable, isNeverBlock, iteratorForAppenders, setDiscardingThreshold, setMaxFlushTime, setNeverBlock, setQueueSizeMethods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, toStringMethods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Constructor Details
-
AsyncBufferFullFallbackAppender
public AsyncBufferFullFallbackAppender()
-
-
Method Details
-
append
protected void append(ch.qos.logback.classic.spi.ILoggingEvent eventObject)Append a log event asynchronously, falling back to the fallback appender ifgetRemainingCapacity() <= fallbackThreshold- Overrides:
appendin classch.qos.logback.core.AsyncAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
preprocess
protected void preprocess(ch.qos.logback.classic.spi.ILoggingEvent eventObject)- Overrides:
preprocessin classch.qos.logback.core.AsyncAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
start
public void start()- Specified by:
startin interfacech.qos.logback.core.spi.LifeCycle- Overrides:
startin classch.qos.logback.core.AsyncAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
stop
public void stop()- Specified by:
stopin interfacech.qos.logback.core.spi.LifeCycle- Overrides:
stopin classch.qos.logback.core.AsyncAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
setUseFallbackAppender
public void setUseFallbackAppender(boolean useFallbackAppender) -
setFallbackThreshold
public void setFallbackThreshold(int fallbackThreshold) -
setFallback
-