[
https://issues.apache.org/jira/browse/LOG4J2-3612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Davis Walsh updated LOG4J2-3612:
--------------------------------
Description:
Before 2.17.2 the default additivity for LoggerConfig was
[true|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java#L747],
but is now
[false|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java#L122].
I think this change was included in [this LOG4J2-3341
commit|https://github.com/apache/logging-log4j2/commit/5a459dda1e731dfa93198db63493c1cb1cd1e941#diff-461d467ccfa2fc222a0481d1c318f1f12e57dd60fb17ef2411c66f133f37fadf]
This has the effect of setting the root LoggerConfig's additivity to false.
While this may not have any impact on the root loggers functionality, it does
have an impact when new Loggers are created programmatically that were
previously defaulting to the root config. For example, when adding an Appender
to such a logger, the root config is used as the basis for the new
LoggerConfig, [including this
additivity|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java#L880].
This means that a Logger that previously logged to the root logger's appenders
will now only log to the newly added Appender.
I've been able to work around this by setting the level on the logger before
adding a new appender, which [hardcodes additivity to true in the new
LoggerConfig|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java#L422].
This seems fragile, especially [given the TODO statement in the
code|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java#L421].
was:
Before 2.17.2 the default additivity for LoggerConfig was
[true|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java#L747],
but is now
[false|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java#L122].
I think this change was included in [this LOG4J2-3341
commit|https://github.com/apache/logging-log4j2/commit/5a459dda1e731dfa93198db63493c1cb1cd1e941#diff-461d467ccfa2fc222a0481d1c318f1f12e57dd60fb17ef2411c66f133f37fadf]
This has the effect of setting the root LoggerConfig's additivity to false.
While this may not have any impact on the root loggers functionality, it does
have an impact when new Loggers create created that were previously defaulting
to the root config. For example, when adding an Appender to such a logger, the
root config is used as the basis for the new LoggerConfig, [including this
affinity|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java#L880].
This means that a Logger that previously logged to the root logger's appenders
will now only log to the newly added Appender.
I've been able to work around this by setting the level on the logger before
adding a new appender, which [hardcodes additivity to true in the new
LoggerConfig|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java#L422].
This seems fragile, especially [given the TODO statement in the
code|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java#L421].
> Root LoggerConfig default for additivity changed in 2.17.2
> ----------------------------------------------------------
>
> Key: LOG4J2-3612
> URL: https://issues.apache.org/jira/browse/LOG4J2-3612
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.18.0, 2.17.2
> Reporter: Davis Walsh
> Priority: Major
> Fix For: 2.17.3, 2.18.1
>
>
> Before 2.17.2 the default additivity for LoggerConfig was
> [true|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java#L747],
> but is now
> [false|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java#L122].
> I think this change was included in [this LOG4J2-3341
> commit|https://github.com/apache/logging-log4j2/commit/5a459dda1e731dfa93198db63493c1cb1cd1e941#diff-461d467ccfa2fc222a0481d1c318f1f12e57dd60fb17ef2411c66f133f37fadf]
>
> This has the effect of setting the root LoggerConfig's additivity to false.
> While this may not have any impact on the root loggers functionality, it does
> have an impact when new Loggers are created programmatically that were
> previously defaulting to the root config. For example, when adding an
> Appender to such a logger, the root config is used as the basis for the new
> LoggerConfig, [including this
> additivity|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java#L880].
> This means that a Logger that previously logged to the root logger's
> appenders will now only log to the newly added Appender.
>
> I've been able to work around this by setting the level on the logger before
> adding a new appender, which [hardcodes additivity to true in the new
> LoggerConfig|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java#L422].
> This seems fragile, especially [given the TODO statement in the
> code|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java#L421].
--
This message was sent by Atlassian Jira
(v8.20.10#820010)