Class BufferedAppender<E>

  • All Implemented Interfaces:
    ch.qos.logback.core.Appender<E>, ch.qos.logback.core.spi.AppenderAttachable<E>, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.FilterAttachable<E>, ch.qos.logback.core.spi.LifeCycle

    public class BufferedAppender<E>
    extends ch.qos.logback.core.AppenderBase<E>
    implements ch.qos.logback.core.spi.AppenderAttachable<E>
    For Logback: Write debug messages only when an error occurs.

    This appender holds back debug messages in a buffer and writes them only out when an error occurs.

    For more flexibility, the BufferedAppender does not write to a file itself. It must be chained with another Appender to produce output.

    You should clear the buffer at the beginning or end of each HTTP request, to ensure that the buffer does not contain old stuff when processing the next HTTP request.

    Example logback.xml

    Stefan Frings,
    • Constructor Detail

      • BufferedAppender

        public BufferedAppender()
    • Method Detail

      • clearBuffer

        public static void clearBuffer()
        Discard buffered messages of the current thread.
      • append

        protected void append​(E event)
        This method is called when a log message got produced. It buffers debug/trace messages until a warning/error occurs.
        Specified by:
        append in class ch.qos.logback.core.AppenderBase<E>
      • setAllowedLevel

        public void setAllowedLevel​(String s)
      • setTriggerLevel

        public void setTriggerLevel​(String s)
      • setBufferSize

        public void setBufferSize​(int size)
      • addAppender

        public void addAppender​(ch.qos.logback.core.Appender<E> newAppender)
        Specified by:
        addAppender in interface ch.qos.logback.core.spi.AppenderAttachable<E>
      • appendLoopOnAppenders

        public int appendLoopOnAppenders​(E e)
      • iteratorForAppenders

        public Iterator<ch.qos.logback.core.Appender<E>> iteratorForAppenders()
        Specified by:
        iteratorForAppenders in interface ch.qos.logback.core.spi.AppenderAttachable<E>
      • getAppender

        public ch.qos.logback.core.Appender<E> getAppender​(String name)
        Specified by:
        getAppender in interface ch.qos.logback.core.spi.AppenderAttachable<E>
      • isAttached

        public boolean isAttached​(ch.qos.logback.core.Appender<E> appender)
        Specified by:
        isAttached in interface ch.qos.logback.core.spi.AppenderAttachable<E>
      • detachAndStopAllAppenders

        public void detachAndStopAllAppenders()
        Specified by:
        detachAndStopAllAppenders in interface ch.qos.logback.core.spi.AppenderAttachable<E>
      • detachAppender

        public boolean detachAppender​(ch.qos.logback.core.Appender<E> appender)
        Specified by:
        detachAppender in interface ch.qos.logback.core.spi.AppenderAttachable<E>
      • detachAppender

        public boolean detachAppender​(String name)
        Specified by:
        detachAppender in interface ch.qos.logback.core.spi.AppenderAttachable<E>