Search code examples
javalogginglogback

Logback - how can you tell AsyncAppender's queue is full and starts dropping events?


Is there a way to know that logback is discarding logging events because the queue is full? Is it logged anywhere?


Solution

  • There is no direct way to do it.

    The Appender silently discards event:

    AsyncAppenderBase.java

        @Override
        protected void append(E eventObject) {
            if (isQueueBelowDiscardingThreshold() && isDiscardable(eventObject)) {
                return;
            }
            preprocess(eventObject);
            put(eventObject);
        }
    

    However, you can create your own appender by extending AsyncAppenderBase or AsyncAppender and override append method with your custom logic.