-> If I recall correctly, you are using a custom `Logger` class. My guess is 
that you overrode the `getEffectiveLevel()` with some custom logic.

Yes Piotr, you are correct. I am overriding this method in my custom logger as 
below. Do you think this could be the problem??


   @Override
   public Level getEffectiveLevel() {
       Level configuredLevel = super.getEffectiveLevel(); 
       if (!isGeneralLogger) 
           return configuredLevel;
       Level currLevel = myLevel.get();
       if (currLevel == null)
           return configuredLevel;
       if (configuredLevel == null) 
           return currLevel;
       if (currLevel.isGreaterOrEqual(configuredLevel))
           return configuredLevel;
       return currLevel;
   }

-----Original Message-----
From: Piotr P. Karwasz <piotr.karw...@gmail.com> 
Sent: Monday, March 7, 2022 6:06 PM
To: Log4J Users List <log4j-user@logging.apache.org>
Subject: Re: Log level settings are not working correctly and getting wrong 
value

*** External email: Verify sender before opening attachments or links ***


Hello Pooja,

On Mon, Mar 7, 2022 at 11:23 AM Pooja Pandey <pooja.pan...@asg.com.invalid> 
wrote:
> I think there is something wrong with Log4j1.x bridge level handling when 
> migrating from log4j1.x to log4j2.x.
>
> Issue: In my config file, log level is set to "Error",  but with log4j1.x 
> bridge log level is getting calculated as DEBUG. I think this is since in 
> log4j1.x from FATAL to DEBUG level integer value decreases as shown below but 
> in log4j2.x from FATAL to DEBUG integer value increases as shown below.

The order of Log4j 2.x numerical levels is the inverse of the Log4j 1.x order. 
However, that should have no influence on the result of 
`org.apache.log4j.Category#getEffectiveLevel()`, if that is the function you 
are referring to.

If I recall correctly, you are using a custom `Logger` class. My guess is that 
you overrode the `getEffectiveLevel()` with some custom logic.
Be aware that in the Log4j 1.x bridge the field `Category#level` is almost 
always `null`, while `Category#getLevel()` is an alias for 
`Category#getEffectiveLevel()` (never `null`).

If that is not the case, can you run your application with 
`-Dlog4j2.debug=true` and send you configuration file and the output of the 
status logger (it's printed to the application's standard error)?

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to