Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logback <logger> level ignored when logs come from jboss-logging

My web application (deployed on tomcat 7) is using hibernate 4.2 which logs using jboss-logging. Jboss logging is finding slf4j on the path and uses it. In turn, I have logback-classic to output the logs. Everything works nicely, but I cannot customize the root logging level, i.e.

<logger name="o.h.cfg.annotations" level="info"/>
<logger name="rest.helpers" level="info"/>

<root level="debug">
    <appender-ref ref="STDOUT" />
</root>

Results in:

logback-test 16:47:03.689 [http-bio-8080-exec-5] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider

logback-test 16:47:04.244 [http-bio-8080-exec-5] DEBUG o.h.cfg.annotations.EntityBinder

logback-test 10:00:11.911 [localhost-startStop-1] INFO rest.helpers.MyApplication

For messages coming from jboss (o.h.cfg.annotations.*), level is set to info, but a debug message is printed. When I use slf4j directly (rest.helpers.*), it correctly filters out my debug messages, and prints my info messages.

Now, if root log level is set to "none", allowing some debug messages will print all of them:

<logger name="o.h.cfg.annotations" level="debug"/>
<logger name="rest.helpers" level="debug"/>
<root level="none"/>

logback-test 10:22:25.926 [localhost-startStop-1] DEBUG rest.helpers.MyApplication -dMyApplication() Aug 2, 2013 10:22:26 AM org.glassfish.jersey.server.ApplicationHandler initialize INFO: Initiating Jersey application

logback-test 10:22:26.253 [localhost-startStop-1] INFO rest.helpers.MyApplication

logback-test 10:22:42.995 [http-bio-8080-exec-5] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider

logback-test 10:22:43.025 [http-bio-8080-exec-5] DEBUG org.hibernate.type.BasicTypeRegistry

I have not allowed org.hibernate debug messages, why did they appear? i verified that the right config file is taken (by changing the log format)

Please help me make sense of this.

My classpath contains

  • slf4j-api 1.6.1
  • jul-to-slf4j 1.6.1
  • log4j-over-slf4j 1.6.1
  • logback-core 1.0.33
  • logback-classic 1.0.33
  • jboss-logging 3.1.0.GA.

Both logback.xml and logback-test.xml are in the classpath. logback.xml contains <root level="warn"> and no further specialization

like image 730
Julian Rozentur Avatar asked Dec 04 '25 02:12

Julian Rozentur


1 Answers

I had the same problem with freemarker however in my case freemarker was not using the log4j-over-slf4j bridge but used log4j directly (i had it in my classpath without knowing (through a maven dependency)).

I discovered the problem when i told logback to log to a file and the freemarker logs still arrived on stdout.

The solution was to explicitly exclude the log4j dependency from a maven lib i used.

like image 198
luke Avatar answered Dec 05 '25 19:12

luke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!