[logback-user] Advice please
Ceki Gülcü
ceki at qos.ch
Wed Jul 21 19:36:20 CEST 2010
Hi Jesse,
See the chapter on logback architecture [1] for the interaction of
loggers and appenders. You might also find the chapter on filters [2].
The MDC [3] and SiftingAppender [4] combination is a very powerful
alternative to the traditional combination of loggers and appenders.
[1] http://logback.qos.ch/manual/architecture.html
[2] http://logback.qos.ch/manual/filters.html
[3] http://logback.qos.ch/manual/mdc.html
[4] http://logback.qos.ch/manual/appenders.html#SiftingAppender
On 21/07/2010 4:02 PM, Jesse Long wrote:
> Hi All,
>
> Please advise me whether the following is possible, and how to go about
> implementing it in Logback.
>
> I have a web app, with servlets for the web pages, as well as soap web
> services. Additionally, I have some background threads that do all sorts
> of interesting things. The servlets, web services and background threads
> all use the same data model classes which are backed by an orm data
> access layer, which uses JDBC to get data from a DB.
>
> I want all logging that happens while handling a servlet request to go
> to one log file, all logging that happens while handling a soap web
> service call to go to another log file, and all logging that happens in
> a background thread to go to another log file. Also, I want to log all
> the data model, orm and JDBC layer information to separate log files at
> debug and up level.
>
> For example, imaging the following list of log events (in this order):
>
> Logger Level Expected log files
> x.soap info soap.log
> x.model info soap.log,model.log
> x.orm debug orm.log
> x.orm info soap.log,model.log,orm.log
> x.jdbc debug jdbc.log
> x.jdbc info soap.log,model.log,orm.log,jdbc.log
>
> x.soap calls x.model, which calls x.orm, which calls x.jdbc. Similar
> traces for x.servlet, x.helperthread etc.
>
> I cant use Logger name to decide which appenders log, but what can I
> use? How can I achieve this?
>
> I would appreciate any pointers.
>
> Thanks,
> Jesse
More information about the Logback-user
mailing list