简体   繁体   中英

How to set the logging level of embedded tomcat in Spring Boot?

How to set the logging level of embedded tomcat in Spring Boot?

Especially I need to see the tomcat clustering-related logs.

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

logging.level.org.apache.catalina=TRACE

Is there a simple method to accomplish this?

It would be best to know the Spring Boot and embedded tomcat-specific, simple solution, preferably only editing application.properties.

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

Spring Boot 1.3.0 adds LevelChangePropagator to LogbackLoggingSystem.java ( see this commit ), thus the logging level that is set in application.properties is propagated to the jul(java.util.logging) which tomcat uses.

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

Also see the following Spring Boot issues: Optimize JUL logging #2585 , Slf4JLoggingSystem should also configure JUL levels #2923 .

And this is the related StackOverflow question: Spring Boot - set logging level of external jar which is using Java Util Logging (jul) . Actually this is the problem I was facing.

(I will accept this answer if no better answer is posted for a few days from now.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM