JIGNESH S SHUKLA created LOG4J2-2315:

             Summary: LevelRangeFilter min and max values are behaving opposit
                 Key: LOG4J2-2315
                 URL: https://issues.apache.org/jira/browse/LOG4J2-2315
             Project: Log4j 2
          Issue Type: Bug
          Components: Filters
    Affects Versions: 2.10.0
            Reporter: JIGNESH S SHUKLA

LevelRangeFilter's minLevel and maxLevel are behaving opposite then it's 
previous (log4j 1.2.X) versions. 

For example, if you set minLevel=DEBUG and maxLevel=INFO, I would expect both 
DEBUG and INFO logs should be in the targeted output and all the other levels 
should be filtered. That's how it used to work in log4j 1.2.x version). 

However, in log4j2, it doesn't really output anything (i.e. it filters out all 
the levels). If you swap the value of minLevel and maxLevel then (i.e. 
minLevel=INFO and maxLevel=DEBUG),  it works as expected. This is very 

Looking at the documentation and code, I think this is happening due to 
 # In Log4j 1.x, the priority value of levels were in ascending order. It means 
INFO will have higher value than DEBUG.  However, in  log4j2.x, the concept is 
different. There is an associated intValue with each level and according to 
documentation, intValues are in descending order. it means DEBUG's intValue 
(500) is higher than INFO's (400). 

2. With this change of priority/intValues from ascending to descending, 
following logic in Level.java never returns true for a minLevel=DEBUG and 
maxLevel=INFO in Log4j2. 

 *public boolean isInRange(final Level minLevel, final Level maxLevel) {*
 *{color:#d04437}return this.intLevel >= minLevel.intLevel && this.intLevel <= 

I think this needs to be corrected as the meaning of minLevel and maxLevel are 
very intuitive and current implement is totally opposite of it and makes it 
very confusing. 


This message was sent by Atlassian JIRA

Reply via email to