How can I disable Spring logs to have log outputs that I can easily read or someone else can read. An answer to a similar question at, how to disable spring bean loading log
Before you do, you should have get some knowledge of :
1.How to add maven dependency
2.Where to put log4j configuration file
OK, return to the question.The top answer is not working for spring 4.x, if you are using spring4.x try following 3 steps:
remove common-logging from spring-core
org.springframework spring-core 4.3.4.RELEASE commons-logging commons-logging Without this step, no matter what you put in log4j configuration file is not working, cause spring is using
common-loggingmy boy!
PS:Within lots of spring modules,spring-coreis the the only module that explicitly depends oncommons-logging.
Add SLF4J and log4j
org.slf4j jcl-over-slf4j 1.5.8 org.slf4j slf4j-api 1.5.8 org.slf4j slf4j-log4j12 1.5.8 log4j log4j 1.2.14
configure log4j.properties(You can also use xml file)
log4j.rootCategory=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
log4j.category.org.springframework.beans.factory=INFO
Now, the annoying spring debug log is going away.Enjoy coding!
The answer is from spring.io doc,for origin click here