[
https://issues.apache.org/jira/browse/LOG4J2-2379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16549383#comment-16549383
]
Ranjit Dsouza commented on LOG4J2-2379:
---------------------------------------
I set the "issue Type" as "Question" as opposed to "Bug", hoping it wouldn't be
seen as a issue.
Ok. I changed the code a bit. I added one line to Configurator.setLevel()
logger = LogManager.getLogger(loggerName);
LoggerConfig loggerConfig =
LoggerContext.getContext(false).getConfiguration().getLoggerConfig(loggerName);
System.out.println("new loggerConfig name: " + loggerConfig.getName());
System.out.println("new loggerConfig parent : " +
loggerConfig.getParent());
Configurator.setLevel(loggerName, Level.TRACE); //This line added
loggerConfig =
LoggerContext.getContext(false).getConfiguration().getLoggerConfig(loggerName);
System.out.println("new loggerConfig name(after seLevel): " +
loggerConfig.getName());
System.out.println("new loggerConfig parent(after seLevel) : " +
loggerConfig.getParent());
Now when I run it, the output shows:
new loggerConfig name:
new loggerConfig parent : null
new loggerConfig name(after seLevel): com.myCompany.myClass
new loggerConfig parent(after seLevel) : root
Why the change in logger name, if Logger is simply configured to use the root
LoggerConfig?
> Is the LoggerConfig name and parent blank for a new logger?
> -----------------------------------------------------------
>
> Key: LOG4J2-2379
> URL: https://issues.apache.org/jira/browse/LOG4J2-2379
> Project: Log4j 2
> Issue Type: Question
> Components: Core
> Affects Versions: 2.11.0
> Reporter: Ranjit Dsouza
> Priority: Major
>
> This is the code snippet, From the output, notice that loggerConfig name is
> blank and its parent is null. Is this how it is supposed to be?
> String loggerName = "com.myCompany.myClass";
> static Logger logger = LogManager.getLogger(loggerName);
> LoggerConfig loggerConfig =
> LoggerContext.getContext(false).getConfiguration().getLoggerConfig(loggerName);
> System.out.println("new loggerConfig name: " + loggerConfig.getName());
> System.out.println("new loggerConfig parent : " + loggerConfig.getParent());
> Output:
> new loggerConfig name:
> new loggerConfig parent : null
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)