You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "Ralph Goers (JIRA)" <ji...@apache.org> on 2017/06/01 11:47:04 UTC
[jira] [Commented] (LOG4J2-1927) Using Configurator.setLevel()
results in a default LoggerConfig
[ https://issues.apache.org/jira/browse/LOG4J2-1927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16032836#comment-16032836 ]
Ralph Goers commented on LOG4J2-1927:
-------------------------------------
Log4J already does this. It will look at the parent LoggerConfig until it hits one with additivity set to false or hits the root LoggerConfig.
> Using Configurator.setLevel() results in a default LoggerConfig
> ---------------------------------------------------------------
>
> Key: LOG4J2-1927
> URL: https://issues.apache.org/jira/browse/LOG4J2-1927
> Project: Log4j 2
> Issue Type: Improvement
> Components: Configurators
> Affects Versions: 2.8.2
> Reporter: Thorkild Gregersen
> Priority: Minor
>
> Using Configurator.setLevel(String, Level) to change log level of a logger results in a new LoggerConfig if non exists before.
> This appear to result in a config with out an Appender.
> Is this desired behavior and what are the side effects of this?
> Could a solution be to inherit the Appender or AppenderRefs from the parent logger/config?
> Code in question from org.apache.logging.log4j.core.config.Configurator
> {code}
> private static boolean setLevel(final String loggerName, final Level level, final Configuration config) {
> boolean set;
> LoggerConfig loggerConfig = config.getLoggerConfig(loggerName);
> if (!loggerName.equals(loggerConfig.getName())) {
> // TODO Should additivity be inherited?
> loggerConfig = new LoggerConfig(loggerName, level, true);
> config.addLogger(loggerName, loggerConfig);
> loggerConfig.setLevel(level);
> set = true;
> } else {
> set = setLevel(loggerConfig, level);
> }
> return set;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)