logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Francis Lalonde (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LOG4J2-1258) Async DynamicThresholdFilter broken
Date Tue, 19 Jan 2016 20:38:40 GMT
Francis Lalonde created LOG4J2-1258:

             Summary: Async DynamicThresholdFilter broken
                 Key: LOG4J2-1258
                 URL: https://issues.apache.org/jira/browse/LOG4J2-1258
             Project: Log4j 2
          Issue Type: Bug
          Components: Filters
    Affects Versions: 2.5
         Environment: -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
            Reporter: Francis Lalonde
            Priority: Minor

Using Log4J 2.5 with AsyncLogger mode enabled. Filtering events at the Appender level using
DynamicThresholdFilter is not working.The filter is basing its decision on the ThreadContext
even though it is filtering an asynchronous event on a worker thread.

    private Result filter(final Level level) {
        final Object value = ThreadContext.get(key); // always returns null, ThreadContext
is empty on disruptor thread
        if (value != null) {

Fixing the DynamicThresholdFilter to use the context from the log event instead produces the
expected filtering behavior :

    private Result filter(final Level level, Map<String, String> context) {
        final Object value = context.get(key);
        if (value != null) {

    public Result filter(final LogEvent event) {
        return filter(event.getLevel(), event.getContextMap());

    public Result filter(final Logger logger, final Level level, final Marker marker, final
Message msg,
                         final Throwable t) {
        return filter(level, ThreadContext.getContext());

ThreadContextMapFilter is built the same way. 

This message was sent by Atlassian JIRA

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message