[
https://issues.apache.org/jira/browse/LOG4J2-3631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17631484#comment-17631484
]
Piotr Karwasz commented on LOG4J2-3631:
---------------------------------------
[~JWT007],
Yes, {{Configurator.setLevel}} must create a {{LoggerConfig}} if no config by
that name exists.
Regarding version {{2.19.1}}, you should ask on the mailing list. Our recent
focus has been on getting 3.x up and running, so development on the 2.x series
has slowed down. {{log4j-api-test}} and {{log4j-core-test}} are mostly
identical to the {{log4j-api}} and {{log4j-core}} artifacts with a {{tests}}
classifier (which are published). The JUnit extensions they provide are focused
on testing the Log4j2 framework and do not have many applications outside of
it: most software components have static loggers and the ability to provide a
different logger context per test do not apply to them.
> 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
> Assignee: Piotr Karwasz
> Priority: Minor
> Fix For: 2.19.1
>
>
> 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)