Thanks a lot, it  makes perfect sense.
I think that i use MDC or NDC(the code works only on server side).
In my code I am able to name a thread an reuse it, so this gives additional
solution.



Bender Heri wrote:
> 
> OK, in the following I denote foo.bar.XY as AppA and com.create.CR as
> AppB and the test.bulk.ZY as UtilityC.
> 
> Possible solutions:
> 
> 1. If the UtilityC is instantiated separatly by AppA and AppB (two
> instances) you are perfectly done by configuring each instance with the
> desired logger:
>    Config:
>       appender A
>       appender B
>       Logger "AppA"
>           with appender A
>       Logger "AppB"
>           with appender B
>       Logger "AppA.UtilityC"
>           with appender A
>       Logger "AppB.UtilityC"
>           with appender B
>    Code:
>       Use the suggestion of jake Kjome from today morning. The
> constructor of SQLStatements wich receives the classname of the calling
> class must then expand the logger name: receivedClassName + "." +
> this.getClass.getSimpleName(). With this logger name you retrieve the
> logger from the repository. If AppA had called the constructor, you get
> the Logger AppA.UtilityC, and so on.
> 
> 
> 2. Supply the desired logger on each call to the UtilityC class:
>     public static void UtilityC.doSomething( Logger aLoggerToUse );
> {...}
>    
>     Drawback: The location info in the log statements would be the
> location of the call to doSomething(). You can avoid this by using in
> the UtilityC the generic call of Logger log():
>     aLoggerToUse.log ( this.getClass.getName(), Level.DEBUG, logMsg,
> aThrowable )
> 
>     
> 3. Since the AppA and AppB run in different threads you could use a MDC
> value within UtilityC in order to distinguish the loggers. Maybe in
> combination with a own Repository-Selector which relies on the actual
> values in MDC. Search the archive, this was discussed a lot, and I
> supplied whole examples.
>  
> I hope you got the hint in which direction you should think. Otherwise
> ask again.
> 
> Heri
> 
>> -----Original Message-----
>> From: Camer38 [mailto:[EMAIL PROTECTED] 
>> Sent: Monday, July 07, 2008 5:23 PM
>> To: log4j-user@logging.apache.org
>> Subject: RE: "additivity" attribute does not work for 
>> user-defined logger but works for root logger.
>> 
>> 
>> Yes, it is a typo.
>> Should be:
>> "I need two full log files for foo.bar.XY and com.create.CR 
>> with all the logs information from test.bulk.ZY"
>> 
>> Yes the foo.bar.XY and com.create.CR are run in different threads.
>> 
>> I want two logs files - one for foo.bar.XY and the second one 
>> for com.create.CR.
>> All of them should have all the calls made in test.bulk.ZY 
>> (treat it as utility class)
>> 
>> "Do you want the logs of test.bulk.ZY which were called by 
>> foo.bar.XY in the log file of foo.bar.XY and the logs of 
>> test.bulk.ZY which were called by com.create.CR in the log 
>> file of com.create.CR"?
>> Yes. the foo.bar.XY and com.create.CR has some logging 
>> messages as well that needs to go to the right log file.
>> 
>> Thanks for helping me with it.
>> M.
>> 
>> 
>> Bender Heri wrote:
>> > 
>> > Questions see inline. 
>> > Heri
>> > 
>> >> -----Original Message-----
>> >> From: Camer38 [mailto:[EMAIL PROTECTED]
>> >> Sent: Monday, July 07, 2008 3:24 PM
>> >> To: log4j-user@logging.apache.org
>> >> Subject: RE: "additivity" attribute does not work for user-defined 
>> >> logger but works for root logger.
>> >> 
>> >> 
>> >> But in my case I hit slightly different problem. 
>> >> The class foo.bar.XY calls lets say test.bulk.ZY and the class 
>> >> com.create.CR calls test.bulk.ZY as well.
>> > 
>> > Do this two classes (foo.bar.XY and com.create.CR) run in different 
>> > threads? Or is it the same thread? -> Influences possible solutions!
>> > 
>> >> 
>> >> I need two full log files for foo.bar.XY and test.bulk.ZY with all 
>> >> the logs information from test.bulk.ZY.
>> > 
>> > Does not make any sense for me. Is it a typo? 
>> ("test.bulk.ZY" in first 
>> > line should be "com.create.CR"?). If so, then next question: Do you 
>> > want the logs of test.bulk.ZY which were called by 
>> foo.bar.XY in the 
>> > log file of foo.bar and the logs of test.bulk.ZY which were 
>> called by 
>> > com.create.CR in the log file of com.create.CR?
>> > Otherwise you have to explain more detailled which log 
>> calls you want 
>> > to appear in which appender.
>> > 
>> > 
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> > 
>> > 
>> > 
>> 
>> --
>> View this message in context: 
>> http://www.nabble.com/%22additivity%22-attribute-does-not-work
>> -for-user-defined-logger-but-works-for-root-logger.-tp18259092
>> p18319243.html
>> Sent from the Log4j - Users mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/%22additivity%22-attribute-does-not-work-for-user-defined-logger-but-works-for-root-logger.-tp18259092p18336177.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to