Class 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_SIZE
      • Fields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase

        name, started
      • Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

        context
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void append​(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
      Append a log event asynchronously, falling back to the fallback appender if getRemainingCapacity() <= fallbackThreshold
      protected void preprocess​(ch.qos.logback.classic.spi.ILoggingEvent eventObject)  
      void setFallback​(FallbackAppenderRef fallback)  
      void setFallbackThreshold​(int fallbackThreshold)  
      void setUseFallbackAppender​(boolean useFallbackAppender)  
      void start()  
      void stop()  
      • 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, setQueueSize
      • 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 interface ch.qos.logback.core.spi.ContextAware

        addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
    • Constructor Detail

      • AsyncBufferFullFallbackAppender

        public AsyncBufferFullFallbackAppender()
    • Method Detail

      • append

        protected void append​(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
        Append a log event asynchronously, falling back to the fallback appender if getRemainingCapacity() <= fallbackThreshold
        Overrides:
        append in class ch.qos.logback.core.AsyncAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
      • preprocess

        protected void preprocess​(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
        Overrides:
        preprocess in class ch.qos.logback.core.AsyncAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
      • start

        public void start()
        Specified by:
        start in interface ch.qos.logback.core.spi.LifeCycle
        Overrides:
        start in class ch.qos.logback.core.AsyncAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
      • stop

        public void stop()
        Specified by:
        stop in interface ch.qos.logback.core.spi.LifeCycle
        Overrides:
        stop in class ch.qos.logback.core.AsyncAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
      • setUseFallbackAppender

        public void setUseFallbackAppender​(boolean useFallbackAppender)
      • setFallbackThreshold

        public void setFallbackThreshold​(int fallbackThreshold)