Logging threads

M

Matthew

Hello... I have 2 classes: one is a threaded class and the other is my
main class. My main class will execute 3 instances of the threaded
class simultaneously. How will I log these 3 threads SEPARATELY? Please
help . . . Thank you . . .
 
E

Ed

Matthew skrev:
Hello... I have 2 classes: one is a threaded class and the other is my
main class. My main class will execute 3 instances of the threaded
class simultaneously. How will I log these 3 threads SEPARATELY? Please
help . . . Thank you . . .

Can you post your code?

The simplest solution would be to have your main class create three
different Log instances and pass them to the three different threaded
instances in their constructors.
 
S

Sebastian Millies

Am 21 Jul 2006 02:43:09 -0700 schrieb Ed:
Matthew skrev:


Can you post your code?

The simplest solution would be to have your main class create three
different Log instances and pass them to the three different threaded
instances in their constructors.

Depends on what you mean by separately. With log4j you could also use
a single log instance logging to a single file and distinguish the log
entries by the Thread IDs (e.g. using Nested Diagnostic Contexts).
-- Sebastian
 
M

Matthew

Sebastian said:
Depends on what you mean by separately. With log4j you could also use
a single log instance logging to a single file and distinguish the log
entries by the Thread IDs (e.g. using Nested Diagnostic Contexts).
-- Sebastian

Hello, Mr. Sebastian. Is it really safe to use Nested Diagnostic
Contexts? I found this article "Think again before adopting the
commons-logging API" in http://www.qos.ch/logging/thinkAgain.jsp ...
Sorry, I'm not familiar.
 
S

Sebastian Millies

Am 21 Jul 2006 19:39:24 -0700 schrieb Matthew:
Hello, Mr. Sebastian. Is it really safe to use Nested Diagnostic
Contexts? I found this article "Think again before adopting the
commons-logging API" in http://www.qos.ch/logging/thinkAgain.jsp ...
Sorry, I'm not familiar.

Well, that article is concerned with using commons logging,
which doesn't support Nested Diagnostic Contexts, which are
a feature of log4j. -- Sebastian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top