
Here is an ASCII diagram which might clarify the point. +---------------------+ +-------------------------+ | yoda context | | kenobi context | +---------------------+ +-------------------------+ | | | | +-------------------+ +------------+ +-----------+ +-----------+ |FILE-yoda appender | |FILE-Kenobi | | FILE-yoda | |FILE-kenobi| +-------------------+ +------------+ +-----------+ +-----------+ | | | | | | | | | | | | | v | | | kenobi.log (file) <-------|--------------- + v | yoda.log (file) <---------------------------+ Due to SiftingAppenders (one per context) there are two distinct FileAppenders (one in each context) writing to the same file. There are four FileAppenders (two per context). Do not cling to the term "same file" as there is a whole explanatory context. If you still do not see the point, that's probably because you are unfamiliar with SiftingAppender. HTH On 28/04/2010 6:14 PM, Dhondt, Edwin wrote:
Isn't the chapter about the situation where you have different web applications that share a common library and more specifically about how to enable logging to go to distinct log files ( a yoda and a Kenobi file) in that particular setting ? If so, then I don't understand why in Kenobi.log, entries with yoda context appear and why it's stated that logging occurs to the same file ? I would have expected that logging within a thread launched "at" yoda would result in log messages to go exclusively to yoda.log, and that logging within a thread launched "at" Kenobi would result in log messages going exclusively to Kenobi.log ? Can you shed a light on that ? What am I not understanding ?
-----Original Message----- From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of Ceki Gülcü Sent: woensdag 28 april 2010 17:50 To: logback users list Subject: Re: [logback-user] Log separation
The example is not wrong. You probably read the chapter too quickly.
On 28/04/2010 5:41 PM, Dhondt, Edwin wrote:
I've just finished reading that chapter.
At first glance it seems that using a combination of JNDIBasedContextDiscriminator and SiftingAppender should solve my problem ?
But then I read on through the example (Yoda, Kenobi) and now I'm confused. Especially because of the following sentence from the example "Note that even if the ch.qos.starwars.shared.Mustafar logger outputs to kenobi.log it is still attached to 'yoda'. Thus, we have two distinct logging contexts logging to the same file, in this case kenobi.log. Each of these contexts reference FileAppender instances, nested within distinct SiftingAppender instances, logging to the same file." So although the solution described (JNDIBasedContextDiscriminator and SiftingAppender) is about how to log to different files from within a shared codebase, the example doesn't seem to support that theory because it says that two distinct logging contexts are logging to the same file. Is the example wrong ? What am I missing ?
Edwin
-----Original Message----- From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of Ceki Gülcü Sent: woensdag 28 april 2010 17:28 To: logback users list Subject: Re: [logback-user] Log separation
Hello Edwin,
The chapter on logging separation [1] should be helpful, in particular the section entitled "Taming static references in shared libraries".
HTH,
[1] http://logback.qos.ch/manual/loggingSeparation.html
On 28/04/2010 4:56 PM, Dhondt, Edwin wrote:
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 methodX => webapp2.log ...
Any advice would be welcome. Thanks, EDH
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user