You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2016/01/19 22:32:39 UTC

[jira] [Resolved] (LOG4J2-1258) Async DynamicThresholdFilter does not use the log event's context map

     [ https://issues.apache.org/jira/browse/LOG4J2-1258?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory resolved LOG4J2-1258.
----------------------------------
       Resolution: Fixed
    Fix Version/s: 2.5.1

In Git master. Please verify and fix.

> Async DynamicThresholdFilter does not use the log event's context map
> ---------------------------------------------------------------------
>
>                 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
>              Labels: newbie
>             Fix For: 2.5.1
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> 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
(v6.3.4#6332)

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


RE: [jira] [Resolved] (LOG4J2-1258) Async DynamicThresholdFilter does not use the log event's context map

Posted by Francis Lalonde <fr...@expedia.com>.
It seems you were faster than me! I'll try to have a diff prepared if I find something else.

Thanks.

-----Original Message-----
From: Gary Gregory (JIRA) [mailto:jira@apache.org] 
Sent: Tuesday, January 19, 2016 4:33 PM
To: log4j-dev@logging.apache.org
Subject: [jira] [Resolved] (LOG4J2-1258) Async DynamicThresholdFilter does not use the log event's context map


     [ https://issues.apache.org/jira/browse/LOG4J2-1258?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory resolved LOG4J2-1258.
----------------------------------
       Resolution: Fixed
    Fix Version/s: 2.5.1

In Git master. Please verify and fix.

> Async DynamicThresholdFilter does not use the log event's context map
> ---------------------------------------------------------------------
>
>                 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
>              Labels: newbie
>             Fix For: 2.5.1
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> 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
(v6.3.4#6332)

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