[logback-user] Log separation

Dhondt, Edwin edwin.dhondt at hp.com
Wed Apr 28 16:56:25 CEST 2010

I've got 4 web applications.  They all have some specific code containing log statements but they also include a common "backend" codebase jar. Code in that common codebase also contains log statements.

I want each of those 4 applications to have their own log file.  That is, I want all log messages for webapp 1 to appear in webapp 1's log file, messages for webapp2 in webapp 2's file and so on.

This is not a problem for the log statements appearing in the code specific to each webapp.

But what about log statements in de common "backend" codebase (included by each of the webapps) ?  How do those log statements "know" when log statements should go to webapp 1's logfile or webapp 2's log file ?  Because that depends on where the calling  thread initiated (in webapp1, 2, ...).
I could augment each of my backend method signatures with a extra context parameter, but I hope there are more transparent solutions ?

User => methodA Webapp1 => backend codebase methodX => webapp1.log
User => methodB Webapp2 => backend codebase method => webapp2.log

Any advice would be welcome.

More information about the Logback-user mailing list