Repository: logging-log4j2 Updated Branches: refs/heads/master 7eba2e962 -> 3a4d9a65f
[LOG4J2-1532] Attributes are not merged properly in composite configurations. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/3a4d9a65 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3a4d9a65 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3a4d9a65 Branch: refs/heads/master Commit: 3a4d9a65f3ab3dc74e7db063b4cea3b14c1f8abd Parents: 7eba2e9 Author: Gary Gregory <[email protected]> Authored: Mon Aug 22 17:16:32 2016 -0700 Committer: Gary Gregory <[email protected]> Committed: Mon Aug 22 17:16:32 2016 -0700 ---------------------------------------------------------------------- .../logging/log4j/core/LoggerContext.java | 26 +++++++++++++------- src/changes/changes.xml | 3 +++ 2 files changed, 20 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3a4d9a65/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java index cfb4945..ce78615 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java @@ -485,7 +485,11 @@ public class LoggerContext extends AbstractLifeCycle * @return The previous Configuration. */ private Configuration setConfiguration(final Configuration config) { - Objects.requireNonNull(config, "No Configuration was provided"); + if (config == null) { + LOGGER.error("No configuration found for context '%s'.", contextName); + // No change, return the current configuration. + return this.configuration; + } configLock.lock(); try { final Configuration prev = this.configuration; @@ -569,14 +573,18 @@ public class LoggerContext extends AbstractLifeCycle LOGGER.debug("Reconfiguration started for context[name={}] at URI {} ({}) with optional ClassLoader: {}", contextName, configURI, this, cl); final Configuration instance = ConfigurationFactory.getInstance().getConfiguration(contextName, configURI, cl); - setConfiguration(instance); - /* - * instance.start(); Configuration old = setConfiguration(instance); updateLoggers(); if (old != null) { - * old.stop(); } - */ - final String location = configuration == null ? "?" : String.valueOf(configuration.getConfigurationSource()); - LOGGER.debug("Reconfiguration complete for context[name={}] at URI {} ({}) with optional ClassLoader: {}", - contextName, location, this, cl); + if (instance == null) { + LOGGER.error("Reconfiguration failed: No configuration found for '%s' at '%s' in '%s'", contextName, configURI, cl); + } else { + setConfiguration(instance); + /* + * instance.start(); Configuration old = setConfiguration(instance); updateLoggers(); if (old != null) { + * old.stop(); } + */ + final String location = configuration == null ? "?" : String.valueOf(configuration.getConfigurationSource()); + LOGGER.debug("Reconfiguration complete for context[name={}] at URI {} ({}) with optional ClassLoader: {}", + contextName, location, this, cl); + } } /** http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3a4d9a65/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 767e097..98c0aee 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -24,6 +24,9 @@ </properties> <body> <release version="2.7" date="2016-MM-DD" description="GA Release 2.7"> + <action issue="LOG4J2-1532" dev="ggregory" type="fix" due-to="Gary Gregory"> + Attributes are not merged properly in composite configurations. + </action> <action issue="LOG4J2-1529" dev="mattsicker" type="fix" due-to="Sridevi Narra"> Attributes are not merged properly in composite configurations. </action>
