[ 
https://issues.apache.org/jira/browse/LOG4J2-3631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17631501#comment-17631501
 ] 

Jeff Thomas commented on LOG4J2-3631:
-------------------------------------

Thx [~pkarwasz] ,

well we are moving to 2.x now and historically our application allowed admins 
to set log levels, add appenders, etc at runtime and persisted them to the 
log4j.xml.  I am exploring how much of this we can support with 2.x - reading 
configuration works well but there isn't much for serializing an existing one. 

But the test "LoggerContextSource" seems to work really well for setting up a 
custom log4j environment for unit-tests and reconfiguring it before/after 
tests.  It was basically exactly the functionality I was hunting for in that 
moment :) but I need it in release form.  As I was googling around I came 
across a few other people looking for similar functionality, so maybe it has 
more application than you think. ;)

 

> 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)

Reply via email to