Revised log levels: less WARN and INFO, fine-tuned DEBUG vs TRACE

Issue: SPR-16946
This commit is contained in:
Juergen Hoeller
2018-07-20 15:05:13 +02:00
parent a410d90439
commit 9a43d2ec20
99 changed files with 461 additions and 486 deletions

View File

@@ -497,8 +497,8 @@ public abstract class BeanUtils {
try {
Class<?> editorClass = cl.loadClass(editorName);
if (!PropertyEditor.class.isAssignableFrom(editorClass)) {
if (logger.isWarnEnabled()) {
logger.warn("Editor class [" + editorName +
if (logger.isInfoEnabled()) {
logger.info("Editor class [" + editorName +
"] does not implement [java.beans.PropertyEditor] interface");
}
unknownEditorTypes.add(targetType);

View File

@@ -150,7 +150,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
try {
this.autowiredAnnotationTypes.add((Class<? extends Annotation>)
ClassUtils.forName("javax.inject.Inject", AutowiredAnnotationBeanPostProcessor.class.getClassLoader()));
logger.info("JSR-330 'javax.inject.Inject' annotation found and supported for autowiring");
logger.trace("JSR-330 'javax.inject.Inject' annotation found and supported for autowiring");
}
catch (ClassNotFoundException ex) {
// JSR-330 API not available - simply skip.

View File

@@ -156,7 +156,7 @@ public class InitDestroyAnnotationBeanPostProcessor
metadata.invokeDestroyMethods(bean, beanName);
}
catch (InvocationTargetException ex) {
String msg = "Invocation of destroy method failed on bean with name '" + beanName + "'";
String msg = "Destroy method on bean with name '" + beanName + "' threw an exception";
if (logger.isDebugEnabled()) {
logger.warn(msg, ex.getTargetException());
}
@@ -165,7 +165,7 @@ public class InitDestroyAnnotationBeanPostProcessor
}
}
catch (Throwable ex) {
logger.error("Failed to invoke destroy method on bean with name '" + beanName + "'", ex);
logger.warn("Failed to invoke destroy method on bean with name '" + beanName + "'", ex);
}
}

View File

@@ -899,13 +899,13 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
Scope previous = this.scopes.put(scopeName, scope);
if (previous != null && previous != scope) {
if (logger.isInfoEnabled()) {
logger.info("Replacing scope '" + scopeName + "' from [" + previous + "] to [" + scope + "]");
if (logger.isDebugEnabled()) {
logger.debug("Replacing scope '" + scopeName + "' from [" + previous + "] to [" + scope + "]");
}
}
else {
if (logger.isDebugEnabled()) {
logger.debug("Registering scope '" + scopeName + "' with implementation [" + scope + "]");
if (logger.isTraceEnabled()) {
logger.trace("Registering scope '" + scopeName + "' with implementation [" + scope + "]");
}
}
}
@@ -1526,8 +1526,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
}
}
else {
if (logger.isWarnEnabled()) {
logger.warn("Bean creation exception on non-lazy FactoryBean type check: " + ex);
if (logger.isInfoEnabled()) {
logger.info("Bean creation exception on non-lazy FactoryBean type check: " + ex);
}
}
onSuppressedException(ex);

View File

@@ -810,22 +810,22 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
else if (existingDefinition.getRole() < beanDefinition.getRole()) {
// e.g. was ROLE_APPLICATION, now overriding with ROLE_SUPPORT or ROLE_INFRASTRUCTURE
if (logger.isWarnEnabled()) {
logger.warn("Overriding user-defined bean definition for bean '" + beanName +
if (logger.isInfoEnabled()) {
logger.info("Overriding user-defined bean definition for bean '" + beanName +
"' with a framework-generated bean definition: replacing [" +
existingDefinition + "] with [" + beanDefinition + "]");
}
}
else if (!beanDefinition.equals(existingDefinition)) {
if (logger.isInfoEnabled()) {
logger.info("Overriding bean definition for bean '" + beanName +
if (logger.isDebugEnabled()) {
logger.debug("Overriding bean definition for bean '" + beanName +
"' with a different definition: replacing [" + existingDefinition +
"] with [" + beanDefinition + "]");
}
}
else {
if (logger.isDebugEnabled()) {
logger.debug("Overriding bean definition for bean '" + beanName +
if (logger.isTraceEnabled()) {
logger.trace("Overriding bean definition for bean '" + beanName +
"' with an equivalent definition: replacing [" + existingDefinition +
"] with [" + beanDefinition + "]");
}

View File

@@ -571,7 +571,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
bean.destroy();
}
catch (Throwable ex) {
logger.error("Destroy method on bean with name '" + beanName + "' threw an exception", ex);
logger.warn("Destroy method on bean with name '" + beanName + "' threw an exception", ex);
}
}

View File

@@ -338,8 +338,8 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
}
}
catch (InvocationTargetException ex) {
String msg = "Invocation of destroy method '" + this.destroyMethodName +
"' failed on bean with name '" + this.beanName + "'";
String msg = "Destroy method '" + this.destroyMethodName + "' on bean with name '" +
this.beanName + "' threw an exception";
if (logger.isDebugEnabled()) {
logger.warn(msg, ex.getTargetException());
}
@@ -348,7 +348,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
}
}
catch (Throwable ex) {
logger.error("Couldn't invoke destroy method '" + this.destroyMethodName +
logger.warn("Failed to invoke destroy method '" + this.destroyMethodName +
"' on bean with name '" + this.beanName + "'", ex);
}
}

View File

@@ -66,7 +66,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
}
catch (Throwable ex) {
// Thrown from the FactoryBean's getObjectType implementation.
logger.warn("FactoryBean threw exception from getObjectType, despite the contract saying " +
logger.info("FactoryBean threw exception from getObjectType, despite the contract saying " +
"that it should return null if the type of its object cannot be determined yet", ex);
return null;
}

View File

@@ -138,8 +138,8 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
// We cannot use Profiles.of(...) since profile expressions are not supported
// in XML config. See SPR-12458 for details.
if (!getReaderContext().getEnvironment().acceptsProfiles(specifiedProfiles)) {
if (logger.isInfoEnabled()) {
logger.info("Skipped XML bean definition file due to specified profiles [" + profileSpec +
if (logger.isDebugEnabled()) {
logger.debug("Skipped XML bean definition file due to specified profiles [" + profileSpec +
"] not matching: " + getReaderContext().getResource());
}
return;

View File

@@ -312,8 +312,8 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
*/
public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
Assert.notNull(encodedResource, "EncodedResource must not be null");
if (logger.isInfoEnabled()) {
logger.info("Loading XML bean definitions from " + encodedResource.getResource());
if (logger.isDebugEnabled()) {
logger.debug("Loading XML bean definitions from " + encodedResource.getResource());
}
Set<EncodedResource> currentResources = this.resourcesCurrentlyBeingLoaded.get();

View File

@@ -95,8 +95,8 @@ public class PropertyComparator<T> implements Comparator<T> {
}
}
catch (RuntimeException ex) {
if (logger.isWarnEnabled()) {
logger.warn("Could not sort objects [" + o1 + "] and [" + o2 + "]", ex);
if (logger.isDebugEnabled()) {
logger.debug("Could not sort objects [" + o1 + "] and [" + o2 + "]", ex);
}
return 0;
}
@@ -119,7 +119,7 @@ public class PropertyComparator<T> implements Comparator<T> {
return this.beanWrapper.getPropertyValue(this.sortDefinition.getProperty());
}
catch (BeansException ex) {
logger.info("PropertyComparator could not access property - treating as null for sorting", ex);
logger.debug("PropertyComparator could not access property - treating as null for sorting", ex);
return null;
}
}