简体   繁体   English

如何在Spring Boot中设置嵌入式tomcat的日志级别?

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

How to set the logging level of embedded tomcat in Spring Boot? 如何在Spring Boot中设置嵌入式tomcat的日志级别?

Especially I need to see the tomcat clustering-related logs. 特别是我需要看到与tomcat集群相关的日志。

I added the following line to the application.properties, but tomcat seems to log only INFO level logs. 我将以下行添加到application.properties,但tomcat似乎只记录INFO级别日志。

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. 最好知道Spring Boot和嵌入式tomcat特有的简单解决方案,最好只编辑application.properties。

In short, use Spring Boot version 1.3.0 with Logback. 简而言之,使用带有Logback的Spring Boot 1.3.0版。 (I was using Spring Boot 1.2.4) (我使用的是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. Spring Boot 1.3.0将LevelChangePropagator添加到LogbackLoggingSystem.java请参阅此提交 ),因此application.properties中设置的日志记录级别将传播到tomcat使用的jul(java.util.logging)。

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. 否则,如果级别低于默认的INFO级别,则必须在jul的logging.properties中设置记录器的日志记录级别,并且还要在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. 这是为了限制jul-to-slf4j模块,因为jul在java。*包中,所以不能完全覆盖jul实现。

Also see the following Spring Boot issues: Optimize JUL logging #2585 , Slf4JLoggingSystem should also configure JUL levels #2923 . 另请参阅以下Spring Boot问题: 优化JUL日志记录#2585Slf4JLoggingSystem还应配置JUL级别#2923

And this is the related StackOverflow question: Spring Boot - set logging level of external jar which is using Java Util Logging (jul) . 这是相关的StackOverflow问题: Spring Boot - 设置使用Java Util Logging(jul)的外部jar的日志记录级别 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.) (如果从现在开始几天没有更好的答案,我会接受这个答案。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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