[
https://issues.apache.org/jira/browse/LOG4J2-3631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17631055#comment-17631055
]
Jeff Thomas commented on LOG4J2-3631:
-------------------------------------
A related background question from my side as well :)
If I get a non-configured Logger, a associated LoggerConfig is _not_ created.
ie. LogManager.getLogger(UUID.randomUUID().toString())
... so if I call "updateLoggers()" it resets the level based on the
configuration of the parent logger.
However, if I get a non-configured Logger by Class as in the example above:
ie. LogManager.getLogger(a.b.c.d.some.package.FooBar.class)
It creates a persisted configuration which becomes the de-facto standard for
future "reconfigure()" and "updateLoggers()" calls.
Is there a reason for the different handling?
> Different handling for "getLogger(Class)" and
> "Configurator.setLevel(Class,Level)" on inner class
> -------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-3631
> URL: https://issues.apache.org/jira/browse/LOG4J2-3631
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.19.0
> Environment: Java 11 (Temurin)
> Maven
> Reporter: Jeff Thomas
> Priority: Major
>
> I have created a sample project with a simple JUnit test here:
> [https://github.com/JWT007/log4j2_logLevelClass]
> Basically I have an inner class and when I get a logger for that class I get
> the logger named.
> {{Log4jLevelTest.InnerClass}}
> and I can see its associated LoggerConfig of the same name.
> If I call "Configurator.setLevel(InnerClass.class, Level.DEBUG)" it does not
> change the level of my logger but rather creates a new LoggerConfig with the
> following name:
> {{Log4jLevelTest$InnerClass}}
> Here the output of my sample test:
>
> {code:java}
>
> ==================================================================================
> Class name :: Log4jLevelTest$InnerClass
>
> ==================================================================================
> Logger name :: Log4jLevelTest.InnerClass
> Logger level :: INFO
> Configured Loggers (1) ::
> o Log4jLevelTest.InnerClass(INFO)
>
> ==================================================================================
> >> Configurator.setLevel(Inner.class, Level.DEBUG)
> Logger name :: Log4jLevelTest.InnerClass
> Logger level :: INFO
> Configured Loggers (1) ::
> o Log4jLevelTest.InnerClass(INFO)
> o Log4jLevelTest$InnerClass(DEBUG)
> {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)