[logback-user] logging output duplicated

Robert Elliot rob at lidalia.org.uk
Mon Dec 1 10:26:14 CET 2008


foo appends all debug and above messages to the file and then because additivity is set to true by default on all loggers the message is passed to the root logger's appenders which will append them to the file (again) and to email.  So you will get each message duplicated in the file.

You could add the email appender to foo as well as root, and set foo's additivity to false.  Then each message will only appear once in the file.

(Incidentally, it sounds like you might be interested in my suggested alteration to logback here: http://jira.qos.ch/browse/LBCLASSIC-82 . It would make it relatively easy to prevent getting all those debug messages emailed to you!  You could also add a filter to the email appender that only allows error messages to be appended.)


----- Original Message -----
From: "Chris Cheshire" <cheshirator at gmail.com>
To: "logback users list" <logback-user at qos.ch>
Sent: Sunday, 30 November, 2008 7:23:43 PM GMT +00:00 GMT Britain, Ireland, Portugal
Subject: [logback-user] logging output duplicated

In my webapp I am trying to send emails only on errors, with
everything else logged to a file. I am using logback under slf4j, with
the log4j/slf4j bridge for the external libraries that normally use
log4j.

My configuration file is reloaded in the servlet context init (using
the Joran configurator example from the documentation) so I can set
some system properties used in the appenders (like the context name).

The logging config has :

  <root level="ERROR">
    <appender-ref ref="EMAIL" />
    <appender-ref ref="FILE" />
  </root>

  <logger name="foo" level="DEBUG">
      <appender-ref ref="FILE" />
  </logger>


*Everything* not of log level ERROR coming from foo is getting logged
twice. Why? I've pored over Chapter 2 of the documentation and it
seems to describe the opposite of what is happening. The level for foo
will ideally swap between DEBUG and INFO, but I can't have things
logged twice all the time. How do I fix this?

Thanks

Chris
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://qos.ch/mailman/listinfo/logback-user


More information about the Logback-user mailing list