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

Jason Tedor commented on LOG4J2-2023:
-------------------------------------

I understand the implications for nested classes, but it's specifically local 
and anonymous classes for which this change is problematic. For these classes, 
their canonical name is null. Previously logging levels for a logger for such a 
class could at least be controlled at say the package level and now instead 
even trying to get a logger by class name for such a logger will blow up (since 
its name is null). I read through the dev list and I do not see any discussion 
on this point.

I start to wonder if maybe the right change here would have been to treat `$` 
also a hierarchical separator in addition to `.`, rather than changing which 
name is used?

> Use a class' canonical name instead of name to create its logger name
> ---------------------------------------------------------------------
>
>                 Key: LOG4J2-2023
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2023
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: API
>            Reporter: Gary Gregory
>            Assignee: Gary Gregory
>             Fix For: 2.9
>
>
> Use a class' canonical name instead of name to create its logger name.
> Say you have loggers built with Classes for which {{getName()}} give you:
> - {{com.example.app.A}}
> - {{com.example.app.A$AS1}}
> - {{com.example.app.A$AS2}}
> - ...
> - {{com.example.app.A$ASN}}
> Before 2.9.0: You you set the root logger to {{WARN}} and 
> {{com.example.app.A}} to {{INFO}}, then you get {{INFO}} events for A but you 
> do not get {{INFO}} messages from {{AS1}}, {{AS2}}, and so on. There is no 
> way to set all {{A$ASx}} loggers to the same level at the same time.
> In 2.9.0 now, converting a Class to a logger name uses 
> {{getCannonicalName()}} such that the logger names are:
> - {{com.example.app.A}}
> - {{com.example.app.A.AS1}}
> - {{com.example.app.A.AS2}}
> - ...
> - {{com.example.app.A.ASN}}
> When you set {{com.example.app.A}} to {{INFO}}, then you get {{INFO}} events 
> for {{A}}, {{AS1}}, {{AS2}}, and so on. 
> The dev ML thread is:
> https://lists.apache.org/thread.html/43b83474aad9c8625e5a6a63d2595c9d795dd6a51076493bacd87a36@%3Cdev.logging.apache.org%3E



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to