How can I set the embedded tomcat logging level in Spring Boot?

How can I set the embedded tomcat logging level in Spring Boot?

Especially I need to look at the logs related to tomcat clusters.

I added the following line to application.properties, but tomcat seems to only log INFO level logs.

logging.level.org.apache.catalina=TRACE

      

Is there an easy way to do this?

Your best bet would be to know Spring Boot and an embedded tomcat specific solution, preferably only editing application.properties.

+3


source to share


1 answer


In short, use Spring Boot version 1.3.0 with Logback feature. (I was using Spring Boot 1.2.4)

Spring Boot 1.3.0 add LevelChangePropagator

to LogbackLoggingSystem.java

( see this commit ) so the logging level that is set in application.properties is propagated to jul (java.util.logging) that tomcat uses.

Otherwise, you need to set the logging level for logging in logging.properties for jul if the level is below INFO, which is the default, and also set the logging level for the logger in application.properties. This is related to a limitation of the jul-to-slf4j module, which cannot completely override the jul implementation, since jul is in the java package. *.



Also see the following Spring Boot Issues: Optimize JUL Entry # 2585 , Slf4JLoggingSystem should also configure JUL Levels # 2923 .

And this is a related StackOverflow question: Spring External Database Bootset Layer using Java Util Logging (jul) . This is actually the problem I was facing.

(I will reply to this answer if a shorter answer is not posted within a few days.)

+3


source







All Articles