Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1911

DynamicThresholdFilter defaultThreshold is not used to compare against event's level when there's no matching key found.

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Documentation
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.8.2
    • None
    • Filters

    Description

      The defaultThreshold property is not honored as documented :

      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.

      after carefully examining the source code, I found the following code is called:

      DynamicThresholdFilter.java
       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;
              }
          }
      

      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.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rgoers Ralph Goers
            metrxqin@gmail.com Jerry Chin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment