How to suppress the log message "Returning a cached instance of a singleton bean"?

How do I suppress a message about returning a singleton bean 'cached instance in Spring / Java? Is there a good link for this somewhere? Thanks.

+4
source share
2 answers

The message "Returning a cached instance of a singleton bean" is registered by Spring at the DEBUG level (at AbstractBeanFactory ). Spring writes a lot of messages at the DEBUG level, by design. If you look at your log files at this level, they will always be full of logarithmic noise like Spring hunters, performing their task.

You cannot suppress certain messages with log4j, the best you can do is suppress certain registrars. However, viewing logs at the DEBUG level is not a good idea if you are not debugging when looking for messages about what Spring is doing deep inside.

For normal operation, you must put the INFO threshold in your log files.

+4
source

Perhaps you are using logging like LOG4J. So, you probably have a log4j.properties file along your classpath.

Add a line there that looks something like this:

 log4j.logger.org.springframework=WARN 
0
source

Source: https://habr.com/ru/post/1301601/


All Articles