Revised log levels: less WARN and INFO, fine-tuned DEBUG vs TRACE
Issue: SPR-16946
This commit is contained in:
@@ -69,15 +69,15 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
||||
throw new IllegalStateException("Cannot define alias '" + alias + "' for name '" +
|
||||
name + "': It is already registered for name '" + registeredName + "'.");
|
||||
}
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Overriding alias '" + alias + "' definition for registered name '" +
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Overriding alias '" + alias + "' definition for registered name '" +
|
||||
registeredName + "' with new target name '" + name + "'");
|
||||
}
|
||||
}
|
||||
checkForAliasCircle(name, alias);
|
||||
this.aliasMap.put(alias, name);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Alias definition '" + alias + "' registered for name '" + name + "'");
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Alias definition '" + alias + "' registered for name '" + name + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,7 +61,7 @@ public final class SpringProperties {
|
||||
URL url = (cl != null ? cl.getResource(PROPERTIES_RESOURCE_LOCATION) :
|
||||
ClassLoader.getSystemResource(PROPERTIES_RESOURCE_LOCATION));
|
||||
if (url != null) {
|
||||
logger.info("Found 'spring.properties' file in local classpath");
|
||||
logger.debug("Found 'spring.properties' file in local classpath");
|
||||
InputStream is = url.openStream();
|
||||
try {
|
||||
localProperties.load(is);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.core.env;
|
||||
|
||||
import java.security.AccessControlException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
@@ -106,7 +107,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
|
||||
private final Set<String> defaultProfiles = new LinkedHashSet<>(getReservedDefaultProfiles());
|
||||
|
||||
private final MutablePropertySources propertySources = new MutablePropertySources(logger);
|
||||
private final MutablePropertySources propertySources = new MutablePropertySources();
|
||||
|
||||
private final ConfigurablePropertyResolver propertyResolver =
|
||||
new PropertySourcesPropertyResolver(this.propertySources);
|
||||
@@ -121,9 +122,6 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
*/
|
||||
public AbstractEnvironment() {
|
||||
customizePropertySources(this.propertySources);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Initialized " + getClass().getSimpleName() + " with PropertySources " + this.propertySources);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -250,6 +248,9 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
@Override
|
||||
public void setActiveProfiles(String... profiles) {
|
||||
Assert.notNull(profiles, "Profile array must not be null");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Activating profiles " + Arrays.asList(profiles));
|
||||
}
|
||||
synchronized (this.activeProfiles) {
|
||||
this.activeProfiles.clear();
|
||||
for (String profile : profiles) {
|
||||
|
||||
@@ -23,9 +23,6 @@ import java.util.Spliterators;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
@@ -44,8 +41,6 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class MutablePropertySources implements PropertySources {
|
||||
|
||||
private final Log logger;
|
||||
|
||||
private final List<PropertySource<?>> propertySourceList = new CopyOnWriteArrayList<>();
|
||||
|
||||
|
||||
@@ -53,7 +48,6 @@ public class MutablePropertySources implements PropertySources {
|
||||
* Create a new {@link MutablePropertySources} object.
|
||||
*/
|
||||
public MutablePropertySources() {
|
||||
this.logger = LogFactory.getLog(getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,14 +61,6 @@ public class MutablePropertySources implements PropertySources {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link MutablePropertySources} object and inherit the given logger,
|
||||
* usually from an enclosing {@link Environment}.
|
||||
*/
|
||||
MutablePropertySources(Log logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator<PropertySource<?>> iterator() {
|
||||
@@ -108,9 +94,6 @@ public class MutablePropertySources implements PropertySources {
|
||||
* Add the given property source object with highest precedence.
|
||||
*/
|
||||
public void addFirst(PropertySource<?> propertySource) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Adding PropertySource '" + propertySource.getName() + "' with highest search precedence");
|
||||
}
|
||||
removeIfPresent(propertySource);
|
||||
this.propertySourceList.add(0, propertySource);
|
||||
}
|
||||
@@ -119,9 +102,6 @@ public class MutablePropertySources implements PropertySources {
|
||||
* Add the given property source object with lowest precedence.
|
||||
*/
|
||||
public void addLast(PropertySource<?> propertySource) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Adding PropertySource '" + propertySource.getName() + "' with lowest search precedence");
|
||||
}
|
||||
removeIfPresent(propertySource);
|
||||
this.propertySourceList.add(propertySource);
|
||||
}
|
||||
@@ -131,10 +111,6 @@ public class MutablePropertySources implements PropertySources {
|
||||
* than the named relative property source.
|
||||
*/
|
||||
public void addBefore(String relativePropertySourceName, PropertySource<?> propertySource) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Adding PropertySource '" + propertySource.getName() +
|
||||
"' with search precedence immediately higher than '" + relativePropertySourceName + "'");
|
||||
}
|
||||
assertLegalRelativeAddition(relativePropertySourceName, propertySource);
|
||||
removeIfPresent(propertySource);
|
||||
int index = assertPresentAndGetIndex(relativePropertySourceName);
|
||||
@@ -146,10 +122,6 @@ public class MutablePropertySources implements PropertySources {
|
||||
* than the named relative property source.
|
||||
*/
|
||||
public void addAfter(String relativePropertySourceName, PropertySource<?> propertySource) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Adding PropertySource '" + propertySource.getName() +
|
||||
"' with search precedence immediately lower than '" + relativePropertySourceName + "'");
|
||||
}
|
||||
assertLegalRelativeAddition(relativePropertySourceName, propertySource);
|
||||
removeIfPresent(propertySource);
|
||||
int index = assertPresentAndGetIndex(relativePropertySourceName);
|
||||
@@ -169,9 +141,6 @@ public class MutablePropertySources implements PropertySources {
|
||||
*/
|
||||
@Nullable
|
||||
public PropertySource<?> remove(String name) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Removing PropertySource '" + name + "'");
|
||||
}
|
||||
int index = this.propertySourceList.indexOf(PropertySource.named(name));
|
||||
return (index != -1 ? this.propertySourceList.remove(index) : null);
|
||||
}
|
||||
@@ -184,9 +153,6 @@ public class MutablePropertySources implements PropertySources {
|
||||
* @see #contains
|
||||
*/
|
||||
public void replace(String name, PropertySource<?> propertySource) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Replacing PropertySource '" + name + "' with '" + propertySource.getName() + "'");
|
||||
}
|
||||
int index = assertPresentAndGetIndex(name);
|
||||
this.propertySourceList.set(index, propertySource);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
Class<?> fileLocatorClass = ClassUtils.forName("org.eclipse.core.runtime.FileLocator",
|
||||
PathMatchingResourcePatternResolver.class.getClassLoader());
|
||||
equinoxResolveMethod = fileLocatorClass.getMethod("resolve", URL.class);
|
||||
logger.debug("Found Equinox FileLocator for OSGi bundle URL resolution");
|
||||
logger.trace("Found Equinox FileLocator for OSGi bundle URL resolution");
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
equinoxResolveMethod = null;
|
||||
@@ -318,8 +318,8 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
path = path.substring(1);
|
||||
}
|
||||
Set<Resource> result = doFindAllClassPathResources(path);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Resolved classpath location [" + location + "] to resources " + result);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Resolved classpath location [" + location + "] to resources " + result);
|
||||
}
|
||||
return result.toArray(new Resource[0]);
|
||||
}
|
||||
@@ -511,8 +511,8 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern));
|
||||
}
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Resolved location pattern [" + locationPattern + "] to resources " + result);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Resolved location pattern [" + locationPattern + "] to resources " + result);
|
||||
}
|
||||
return result.toArray(new Resource[0]);
|
||||
}
|
||||
@@ -634,8 +634,8 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
}
|
||||
|
||||
try {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Looking for matching resources in jar file [" + jarFileUrl + "]");
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Looking for matching resources in jar file [" + jarFileUrl + "]");
|
||||
}
|
||||
if (!"".equals(rootEntryPath) && !rootEntryPath.endsWith("/")) {
|
||||
// Root entry path must end with slash to allow for proper matching.
|
||||
@@ -698,8 +698,8 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
rootDir = rootDirResource.getFile().getAbsoluteFile();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Cannot search for matching files underneath " + rootDirResource +
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Cannot search for matching files underneath " + rootDirResource +
|
||||
" because it does not correspond to a directory in the file system", ex);
|
||||
}
|
||||
return Collections.emptySet();
|
||||
@@ -718,8 +718,8 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
* @see org.springframework.util.PathMatcher
|
||||
*/
|
||||
protected Set<Resource> doFindMatchingFileSystemResources(File rootDir, String subPattern) throws IOException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Looking for matching resources in directory tree [" + rootDir.getPath() + "]");
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Looking for matching resources in directory tree [" + rootDir.getPath() + "]");
|
||||
}
|
||||
Set<File> matchingFiles = retrieveMatchingFiles(rootDir, subPattern);
|
||||
Set<Resource> result = new LinkedHashSet<>(matchingFiles.size());
|
||||
@@ -748,14 +748,14 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
}
|
||||
if (!rootDir.isDirectory()) {
|
||||
// Complain louder if it exists but is no directory.
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Skipping [" + rootDir.getAbsolutePath() + "] because it does not denote a directory");
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Skipping [" + rootDir.getAbsolutePath() + "] because it does not denote a directory");
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
if (!rootDir.canRead()) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Cannot search for matching files underneath directory [" + rootDir.getAbsolutePath() +
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Cannot search for matching files underneath directory [" + rootDir.getAbsolutePath() +
|
||||
"] because the application is not allowed to read the directory");
|
||||
}
|
||||
return Collections.emptySet();
|
||||
@@ -780,8 +780,8 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
* @throws IOException if directory contents could not be retrieved
|
||||
*/
|
||||
protected void doRetrieveMatchingFiles(String fullPattern, File dir, Set<File> result) throws IOException {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Searching directory [" + dir.getAbsolutePath() +
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Searching directory [" + dir.getAbsolutePath() +
|
||||
"] for files matching pattern [" + fullPattern + "]");
|
||||
}
|
||||
for (File content : listDirectory(dir)) {
|
||||
@@ -813,8 +813,8 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
protected File[] listDirectory(File dir) {
|
||||
File[] files = dir.listFiles();
|
||||
if (files == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Could not retrieve contents of directory [" + dir.getAbsolutePath() + "]");
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Could not retrieve contents of directory [" + dir.getAbsolutePath() + "]");
|
||||
}
|
||||
return new File[0];
|
||||
}
|
||||
|
||||
@@ -174,8 +174,8 @@ public abstract class PropertiesLoaderSupport {
|
||||
protected void loadProperties(Properties props) throws IOException {
|
||||
if (this.locations != null) {
|
||||
for (Resource location : this.locations) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loading properties file from " + location);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Loading properties file from " + location);
|
||||
}
|
||||
try {
|
||||
PropertiesLoaderUtils.fillProperties(
|
||||
@@ -183,8 +183,8 @@ public abstract class PropertiesLoaderSupport {
|
||||
}
|
||||
catch (FileNotFoundException | UnknownHostException ex) {
|
||||
if (this.ignoreResourceNotFound) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Properties resource not found: " + ex.getMessage());
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Properties resource not found: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user