diff --git a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java index 478b4615..11fdd8f4 100644 --- a/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java +++ b/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/client/ConfigServicePropertySourceLocator.java @@ -19,6 +19,7 @@ package org.springframework.cloud.config.client; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -93,10 +94,7 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator Environment result = getRemoteEnvironment(restTemplate, properties, label.trim(), state); if (result != null) { - logger.info(String.format("Located environment: name=%s, profiles=%s, label=%s, version=%s, state=%s", - result.getName(), - result.getProfiles() == null ? "" : Arrays.asList(result.getProfiles()), - result.getLabel(), result.getVersion(), result.getState())); + log(result); if (result.getPropertySources() != null) { // result.getPropertySources() can be null if using xml for (PropertySource source : result.getPropertySources()) { @@ -139,6 +137,29 @@ public class ConfigServicePropertySourceLocator implements PropertySourceLocator } + private void log(Environment result) { + if (logger.isInfoEnabled()) { + logger.info(String.format("Located environment: name=%s, profiles=%s, label=%s, version=%s, state=%s", + result.getName(), + result.getProfiles() == null ? "" : Arrays.asList(result.getProfiles()), + result.getLabel(), result.getVersion(), result.getState())); + } + if (logger.isDebugEnabled()) { + List propertySourceList = result.getPropertySources(); + if (propertySourceList != null) { + int propertyCount = 0; + for (PropertySource propertySource: propertySourceList) { + propertyCount += propertySource.getSource().size(); + } + logger.debug(String.format("Environment %s has %d property sources with %d properties.", + result.getName(), + result.getPropertySources().size(), + propertyCount)); + } + + } + } + private void putValue(HashMap map, String key, String value) { if (StringUtils.hasText(value)) { map.put(key, value);