You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "Ralph Goers (JIRA)" <ji...@apache.org> on 2017/05/27 06:55:04 UTC

[jira] [Resolved] (LOG4J2-1911) DynamicThresholdFilter defaultThreshold is not used to compare against event's level when there's no matching key found.

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

Ralph Goers resolved LOG4J2-1911.
---------------------------------
    Resolution: Fixed

I have changed the documentation of the DynamicThresholdFilter to add "If the log event does not contain the specified ThreadContext item NEUTRAL will be returned."

I have added documentation on the key attribute.

I have modified the documentation of defaultThreshold to read "The default threshold only applies if the log event contains the specified ThreadContext Map item and its value does not match any key in the key/value pairs."

Please verify and close.

> DynamicThresholdFilter defaultThreshold is not used to compare against event's level when there's no matching key found.
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1911
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1911
>             Project: Log4j 2
>          Issue Type: Documentation
>          Components: Filters
>    Affects Versions: 2.8.2
>            Reporter: Jerry Chin
>            Assignee: Ralph Goers
>            Priority: Minor
>              Labels: documentation, patch
>
> The {{defaultThreshold}} property is not honored as documented :
> {quote}
> defaultThreshold	Level of messages to be filtered. If there is no matching key in the key/value pairs then this level will be compared against the event's level.
> {quote}
> after carefully examining the source code, I found the following code is called:
> {code:title=DynamicThresholdFilter.java|borderStyle=solid}
>  private Result filter(Level level, ReadOnlyStringMap contextMap) {
>         String value = (String)contextMap.getValue(this.key);
>         if(value != null) {
>             Level ctxLevel = (Level)this.levelMap.get(value);
>             if(ctxLevel == null) {
>                 ctxLevel = this.defaultThreshold;
>             }
>             return level.isMoreSpecificThan(ctxLevel)?this.onMatch:this.onMismatch;
>         } else {
>             return Result.NEUTRAL;
>         }
>     }
> {code}
> where level is the event's level, when there's no matching key found {{contextMap}}, {{Result.NEUTRAL}} is mistakenly returned, instead of against {{this.defaultThreshold}}.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)