views:

60

answers:

2

I am using Jetty 6.1.24 to develop a Web Service and my code uses slf4j, as Jetty does, and logging is working fine. What I want to do though is get debug logging from my code but not from Jetty (it's too verbose), but I cannot stop it from logging debug info. There are system properties to set debug mode (-DDEBUG), but not to unset debug mode.

My logback log level is set by the start script by setting the system property 'loglevel' and this in turn sets it in my resources/logback.xml:

<configuration>
  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
      <Pattern>%d [%thread] %level %logger - %m%n</Pattern>
    </layout>
  </appender>
  <root level="${loglevel:-INFO}">
    <appender-ref ref="CONSOLE"/>
  </root>
</configuration>

Jetty is either always generating debug logs, which are then ignored by the logger if debug is not enabled, or else it's using logger.isDebugEnabled() to set it's debug mode. Does anyone have any ideas on how to get this working?

A: 

See here on how to control logging: http://docs.codehaus.org/display/JETTY/Debugging

Romain Hippeau
That doesn't work I'm afraid - as I already mentioned, Jetty generates debug log messages even when "-DDEBUG" isn't specified on the command line.
trojanfoe
+1  A: 

The -DDEBUG option is only used if you use the StdErr logger. If it's set-up to use slf4j logging (e.g. you've added slf4j onto your classpath), then all the configuration is handled through your slf4j implementation, and the system properties are ignored.

What you want to do configure logback to turn off debug on the jetty log category.

Something like <logger name="org.mortbay.log" level="INFO" />

Tim
This looks like a reasonable answer - thanks. I will look into it and get back to you shortly.
trojanfoe