5

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?

kuceram
  • 3,795
  • 9
  • 34
  • 54
  • `logging.level.` doesn't match anything. I would expect `logging.level.*` to work. Else specify the FQN or atl east base package. – M. Deinum Aug 19 '14 at 08:30
  • 1
    logging.level.ROOT would set the default logger level. – Dave Syer Aug 19 '14 at 11:15
  • M. Deinum sorry it is just typo @Dave I also tried it but it doesn't log from that library which is using JUL either... I also tried to use the logback.xml setting with same result. Is it possible that the logback - jul bridge is not set properly I see logback-core-1.1.2.jar and logback-classic-1.1.2.jar but not the bridge jar – kuceram Aug 21 '14 at 15:28
  • You definitely need to bridge, but if you use `spring-boot-starter-*` for your dependencies that should be there. – Dave Syer Aug 21 '14 at 18:12
  • I have this dependency in my `build.gradle compile 'org.springframework.boot:spring-boot-starter-logging'` so is there any difference to `spring-boot-starter-*`? My Spring Boot version is 1.1.4.RELEASE – kuceram Aug 22 '14 at 06:55
  • Possible duplicate of [How to set the logging level of embedded tomcat in Spring Boot?](http://stackoverflow.com/questions/33730242/how-to-set-the-logging-level-of-embedded-tomcat-in-spring-boot) – Nathan Hughes Nov 18 '15 at 13:29

2 Answers2

1

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 )

1

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

In short, use Spring Boot version 1.3.0 with Logback.

Community
  • 1
  • 1
zeodtr
  • 10,645
  • 14
  • 43
  • 60
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/10241821) – Jeen Broekstra Nov 18 '15 at 04:45
  • @JeenBroekstra What do you mean? This is the answer. The user can solve the problem with Spring Boot version 1.3.0 and logback, since Spring Boot 1.3.0 added a feature related to this question. – zeodtr Nov 18 '15 at 04:51
  • apologies, you're right. I misread and thought you only provided a link, in which case it should have been a comment, not an answer. I overlooked the last bit. – Jeen Broekstra Nov 18 '15 at 04:52
  • @NathanHughes No, I'll wait a few days before accepting my own answer for better answer than mine. But meanwhile others can be helped by this answer since this answer solves the problem anyway. Regarding the close vote, I think they are two separate questions those happened to have the same cause and therefore the same answer. So it's better to be two separate ones. – zeodtr Nov 18 '15 at 13:36