From 70e3588fd823804fb783080fc6306f7947f4b2dc Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 7 Sep 2015 09:46:09 +0100 Subject: [PATCH] Re-initialize logging if anything shows up in logging.* --- .../config/PropertySourceBootstrapConfiguration.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapConfiguration.java b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapConfiguration.java index 3e84fe60..5423386b 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapConfiguration.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapConfiguration.java @@ -20,12 +20,14 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.bind.PropertySourcesPropertyValues; import org.springframework.boot.bind.RelaxedDataBinder; +import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.logging.LogFile; import org.springframework.boot.logging.LoggingInitializationContext; @@ -43,7 +45,6 @@ import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; import org.springframework.core.env.StandardEnvironment; import org.springframework.util.ResourceUtils; -import org.springframework.util.StringUtils; /** * @author Dave Syer @@ -99,11 +100,10 @@ public class PropertySourceBootstrapConfiguration private void reinitializeLoggingSystem(ConfigurableEnvironment environment, String oldLogConfig, LogFile oldLogFile) { - String logConfig = environment.resolvePlaceholders("${logging.config:}"); - LogFile logFile = LogFile.get(environment); - if ((StringUtils.hasText(logConfig) && !logConfig.equals(oldLogConfig) - || (logFile != null && !logFile.toString() - .equals(oldLogFile == null ? null : oldLogFile.toString())))) { + Map props = new RelaxedPropertyResolver(environment).getSubProperties("logging."); + if (!props.isEmpty()) { + String logConfig = environment.resolvePlaceholders("${logging.config:}"); + LogFile logFile = LogFile.get(environment); LoggingSystem system = LoggingSystem .get(LoggingSystem.class.getClassLoader()); try {