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 Klaus Mueller <k....@intershop.de> on 2002/01/18 15:21:48 UTC

Log one thread only

Hi,

I use the log4j package with a multithreaded application server. I need to
log the processing of one thread only. Each thread runs the same classes. I
can not change the categories of this one interesting thread. I can only
specify the name of the thread.

Question:
Does anyone know how to limit the logging to one thread only?

Example:

I create 3 calculator threads:

----
t1|t2|t3 = new CalcThread();
Logger.setLogThread(t2);

t1|t2|t3.start();
----

I need the log output of thread t2 only.

Thanks
KLaus

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Log one thread only

Posted by Kevin Steppe <ks...@pacbell.net>.
A few thoughts:
1) I wouldn't go with the NDC/MDC.  The thread information is already passed
along to the appender.
2) The custom appender -- check the thread in the same way PatternLayout does.
3) Wrap the Logger class and check the thread before forwarding the logging
calls.  This could help performance as the thread is checked early in the method
call chain rather than later.

Kevin

Klaus Mueller wrote:

> Hi,
>
> I use the log4j package with a multithreaded application server. I need to
> log the processing of one thread only. Each thread runs the same classes. I
> can not change the categories of this one interesting thread. I can only
> specify the name of the thread.
>
> Question:
> Does anyone know how to limit the logging to one thread only?
>
> Example:
>
> I create 3 calculator threads:
>
> ----
> t1|t2|t3 = new CalcThread();
> Logger.setLogThread(t2);
>
> t1|t2|t3.start();
> ----
>
> I need the log output of thread t2 only.
>
> Thanks
> KLaus
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>