Spring Boot - set logging level of external jar wh

2019-05-05 19:34发布

According to the Spring Boot documentation, it is possible to set the logging level of multiple logging framework (jul, slf4j, etc.) just by using the Spring Boot Logging Starter and setting appropriate logging.level in application properties. Everything works fine except that the library I use is logging with jul and log level Level.FINER. However, Level.INFO is properly logged.

I set level in application.properties to:

logging.level.=TRACE

which should log everything according to SLF4JBridgeHandler.

Am I something missing or is it a problem of logback (used by the starter) rather my misunderstanding?

2条回答
来,给爷笑一个
2楼-- · 2019-05-05 20:07

SLF4JBridgeHandler only receives LogRecord from enabled levels on jul Loggers (this fact is hidden in the javadoc of the install method)

As the default JUL configuration only logs INFO or higher level, the bridge doesn't receive FINE/FINER/FINEST levels.

In order to test this you can force the level of the root jul logger like this :

LogManager.getLogManager().getLogger("").setLevel(Level.FINE);

(or configure explicitly a custom logging.properties with .level=FINE on your JVM)

This configuration must be completed with slf4j level configuration (via logback.xml or logging.level.xxxxxx properties in application.properties)

( Please note, you should be more specific in your jul production configuration as slf4j documentation warns about performance impact of "jul enabled" but "slf4j disabled" logs )

查看更多
再贱就再见
3楼-- · 2019-05-05 20:07

Please see my related answer: https://stackoverflow.com/a/33770877/3004042

In short, use Spring Boot version 1.3.0 with Logback.

查看更多
登录 后发表回答