I should also point out that if you convert Log4j 1.2 isGreaterOrEqual to 
Level.isGreaterOrEqual in Log4j 2 you are going to get the exact opposite of 
what you want.  I have no idea why at this point, but the level values in Log4j 
2 increase in the opposite order of Log4j 1, so the equivalent method in Log4j 
2 to isGreaterOrEqual is Level.isAtLeastAsSpecificAs.

Again, this is one of the reasons why the Greater and Less than methods should 
be dumped.  The actual enum value shouldn’t matter.

Ralph



On Mar 24, 2014, at 2:12 PM, Ralph Goers <[email protected]> wrote:

> This is one of the things that irks me about the level hierarchy (nothing to 
> be done about that though).
> 
> In a Filter it isn’t obvious whether a level has a higher or lower integer 
> value without looking at the enum values.  This is why the method is named 
> isAtLeastAsSpecificAs since it is clearer that   Debug is at least as 
> specific as Warn.  
> 
> On the other hand, for efficiency Logger just does return intLevel >= 
> Level.intLevel.  
> 
> From what I can tell the lessOrEqual methods (in my code I don’t see any 
> isLessOrEqual methods) are not used anywhere within Log4j so I would prefer 
> dumping these methods.
> 
> Ralph
> 
> On Mar 24, 2014, at 1:16 PM, Gary Gregory <[email protected]> wrote:
> 
>> In the Level class we have:
>> 
>> org.apache.logging.log4j.Level.isAtLeastAsSpecificAs(int)
>> org.apache.logging.log4j.Level.isAtLeastAsSpecificAs(Level)
>> 
>> Which is implemented the same as way:
>> 
>> org.apache.logging.log4j.Level.isLessOrEqual(int)
>> org.apache.logging.log4j.Level.isLessOrEqual(Level)
>> 
>> For compatibility with 1.2 (the server I am porting to v2 does not compile), 
>> I added:
>> 
>> org.apache.logging.log4j.Level.isGreaterOrEqual(Level)
>> 
>> and to match the above I also added:
>> 
>> org.apache.logging.log4j.Level.isGreaterOrEqual(int)
>> 
>> What to do about the duplication?
>> 
>> Internally we use isAtLeastAsSpecificAs().
>> 
>> I am inclined to dump isAtLeastAsSpecificAs in favor of isLessOrEqual.
>> 
>> Thoughts?
>> 
>> Gary
>> 
>> -- 
>> E-Mail: [email protected] | [email protected] 
>> Java Persistence with Hibernate, Second Edition
>> JUnit in Action, Second Edition
>> Spring Batch in Action
>> Blog: http://garygregory.wordpress.com 
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
> 

Reply via email to