views:

182

answers:

2

How do I suppress the 'Returning cached instance of singleton bean' logging message in Spring/Java? Is there a good reference for this somewhere? Thanks.

+1  A: 

Probably you are using logging, through for example LOG4J. So, you probably have a log4j.properties file on your classpath.

Add a line in there that looks something like this:

log4j.logger.org.springframework=WARN
Hans Westerbeek
or better `log4j.logger.org.springframework.beans.factory.support=WARN`
Bozho
I want to suppress specific messages, not change the logging level. :|
Josh
+1  A: 

The "Returning cached instance of singleton bean" message is logged by Spring at DEBUG level (by AbstractBeanFactory). Spring logs a lot of messages at DEBUG level, by design. If you're viewing your log files at this level, then they're invariably going to be full of log noise as Spring chunters along doing its thing.

You can't suppress specific messages with log4j, the best you can do is suppress specific loggers. However, viewing logs at DEBUG level is just not a good idea unless you're debugging, when you're looking for messages on what Spring's doing deep inside.

For normal work, you should be putting a threshold of INFO on your log files.

skaffman