logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francis Lalonde <fralalo...@expedia.com>
Subject Async DynamicThresholdFilter broken?
Date Tue, 19 Jan 2016 19:51:53 GMT
Hello Log4J users,

I am using Log4J 2.5 with AsyncLogger mode enabled. I am trying to filter events at the Appender
level using DynamicThresholdFilter but it is not working.

I believe this is because 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) {

I fixed the DynamicThresholdFilter to use the context from the log event instead,  and it
 gave me 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. Unless I am mistaken and forgot some basic tenement
of log4j usage, this make these Filters useless in async mode elsewhere than Context-wide.

Should I keep  on using my fixed version of the Filter or should I submit a tentative fix?
If so, please tell me what is the procedure to do so.

Thank you,


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message