Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress log message 'Returning cached instance of singleton bean'?

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.

like image 500
Josh Avatar asked Feb 17 '10 17:02

Josh


1 Answers

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.

like image 86
skaffman Avatar answered Sep 20 '22 08:09

skaffman