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

查看:469
本文介绍了如何在Spring Boot中设置嵌入式tomcat的日志记录级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

特别是我需要查看与tomcat群集相关的日志.

我在application.properties中添加了以下行,但是tomcat似乎只记录了INFO级别的日志.

logging.level.org.apache.catalina=TRACE

有没有简单的方法可以做到这一点?

最好了解一下Spring Boot和嵌入式的特定于Tomcat的简单解决方案,最好仅编辑application.properties.

解决方案

简而言之,将Spring Boot版本1.3.0与Logback一起使用. (我使用的是Spring Boot 1.2.4)

Spring Boot 1.3.0将LevelChangePropagator添加到LogbackLoggingSystem.java(请参见),因此application.properties中设置的日志记录级别将传播到tomcat使用的jul(java.util.logging).

否则,如果该级别低于默认值INFO级别,则必须在jul的logging.properties中设置记录器的日志记录级别,并且还必须在application.properties中设置记录器的日志记录级别.这是由于jul-to-slf4j模块的局限性,因为jul在java.*包中,所以无法完全覆盖jul实现.

另请参阅以下Spring Boot问题:优化JUL日志记录#2585 Slf4JLoggingSystem还应配置JUL级别#2923 .. >

这是与StackOverflow相关的问题: 解决方案

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.)

这篇关于如何在Spring Boot中设置嵌入式tomcat的日志记录级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆