[logback-user] Log separation

Ceki Gülcü ceki at qos.ch
Thu Apr 29 10:27:53 CEST 2010


On 29/04/2010 9:33 AM, Ralph Goers wrote:


 > What you are asking to do can be done by having a logger for the
 > classes in the common jar (presumably they are all using the same
 > package name at some level) that is configured with 2 appenders. Each
 > appender is then configured with a filter so that it only allows data
 > from the relevant webapp to be written to that particular file. If you
 > are capturing the request URL or something else that identifies the
 > particular webapp and placing it in the MDC then you can use the
 > EvaluatorFilter (or write your own) to do the filtering.


That's essentially what SiftingAppender does. Note that your solution
suffers from the same exact contention problem that Edwin seems to
dislike. Also in [1] you only need to configure one SiftingAppender
per web-app and it will transparently deal with the order in which
web-apps are started. In your approach, either you have to elect one
web-app, say ADAM, to start first and in ADAMS's logback.xml configure
one additional appender per web-app. Whenever a webb-app is added you
would need to adapt ADAM's web-app by hand. If you can't elect a
web-app to start first, then you would need to add an appender per
web-app in each web-app by hand which would be horrible to maintain
beyond two web-apps.

The solution described in [1] is not so different than yours, except
that it automates a lot of the grunt work.

[1] http://logback.qos.ch/manual/loggingSeparation.html

--
Ceki


More information about the Logback-user mailing list