At 04:08 PM 15/08/2001, Chien Wei Tan wrote:


>Hi,
>
>How would I use log4j to distinguish the log messages coming from different
>instances of the same class?
>
>Eg. MyClass m1 = new MyClass(); // output log messages to MyLog.log
>     MyClass m2 = new MyClass(); // output log messages to MyLog.log, and
>MyOtherLog.log
>     MyClass m3 = new MyClass(); // output log messages to MyOtherLog.log
>     MyClass m4 = new MyClass(); // output log messages to MyOtherLog.log,
>and MyLog.log
>
>
>if the above classes output log messages to MyLog.log and MyOtherLog.log,
>how can i differentiate from the log messages, which instance of MyClass is
>the source?????
>
>In addition, 1) if m1, m2, m3, m4 were all running from the same location,
>                 2) and what if they were distributed and running from 
> different
>locations?

What feature of the class distinguishes each instance (the default being 
the address in memory).?

You could use an NDC to log that see the examples for usage of NDC's - in 
particular SortAlgo.java) or prefix every log output with 'this', e.g. 
logger.debug(this+"My message").

Does that help?

Robert


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

Reply via email to