You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by DE BENEDICTIS DAVIDE <dd...@sogei.it> on 2004/07/15 14:37:24 UTC

One file for every thread

Hi,
I'm logging a server app with a thread pool in which every worker
instance perform the same task.
How can I log every thread activity in a separate file?
I set explicity thread's name and I have a different logger for every
thread name. But now the problem is logging per thread from all classes
called by originating thread. Is there a log4j feature which permits to
mantain all logging inside a thread context?.

Thank you in advance

--
Davide

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: One file for every thread

Posted by Glenn Strickland <gs...@kmobjects.com>.
I think the suggested way of dealing with a multi-threaded server is not
to log each threads output to a separate file, but to tag each log
record with an identifier unique to that thread, then log them to the
same file. You can do this easily with either NDC (Nested Diagnostic
Context) or MDC (Mapped Diagnostic Context). Details are found in the
short manual (http://logging.apache.org/log4j/docs/manual.html) or in
Ceki Gülcü's excellent book, "log4j, the complete manual." 

Glenn Strickland
Knowledge Management Objects


-----Original Message-----
From: DE BENEDICTIS DAVIDE [mailto:ddebenedictis@sogei.it] 
Sent: Thursday, July 15, 2004 8:37 AM
To: log4j-user@logging.apache.org
Subject: One file for every thread


Hi,
I'm logging a server app with a thread pool in which every worker
instance perform the same task.
How can I log every thread activity in a separate file?
I set explicity thread's name and I have a different logger for every
thread name. But now the problem is logging per thread from all classes
called by originating thread. Is there a log4j feature which permits to
mantain all logging inside a thread context?.

Thank you in advance

--
Davide

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org