logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack, Adam" <Adam.J...@New-Era-of-Networks.com>
Subject RE: NDC mix-up
Date Sat, 08 Dec 2001 17:54:45 GMT
Nothing like posting to a mailing list to *immediately* show you something
you'd been staring at, but missed for weeks. :-)

I just noticed that I get this whenever [Thread-0] shows up also. Is thread
zero (whatever that signifies) something special in Log4J NDC? 

I suspect that my app server come JSP engine is using a thread at start-up
(which just so happens to initialise the Log4J sub-system for my components)
and the start-up thread gets released into a thread pool. Later my JSP pages
use the pool -- and occasionally stumble into thread zero -- hence
intermittently putting out all NDCs not just the one.

I doubt I have *any* control over thread use/re-use, and I don't know if I
can initialise log4j differently (to avoid this zero thread, or if the zero
thread is just the one log4j was initialised within).

Ideas appreciated...


>  -----Original Message-----
> From: 	Jack, Adam  
> Sent:	Saturday, December 08, 2001 10:25 AM
> To:	'log4j-user@jakarta.apache.org'
> Subject:	NDC mix-up
> Hi,
> Intermittently I am seeing all the NDCs (in theoretically different
> threads) in a single log entry. They seem to get mixed-up and all be
> displayed.
> I have the following scenario:
> 1)	JSP pages & components in a single app server (in single VM)
> 	Log4J configure to use the SocketClient to talk to a single
> SocketServer
> 2)	Log4J SocketServer configured to append to NT Event Log
> I do this because (1) I couldn't get the NT Event Log appender to work in
> the app server (long painful DLL story) and (2) to centralize things.
> Now:
> The app server does manage threads (& JSP pages can re-use threads that
> are returned to the pool) --- but if it were something like me not
> cleaning the NDC stack I'd expect one or two NDCs to get mixed-up, not
> all. It is all of them.
> I do configure the Log4J sub-system once, in a single thread [not once per
> thread], but I get my categories within the thread I am working inside
> (from the single instance of Log4J).
> To push onto the NDC I do just this --- I am (from my reading) assuming
> that the NDC manages a stack as a ThreadLocal object and so long as I do
> this in my thread, and pop when my thread dies, then I am using NDC
> correctly:
>                 NDC.push( "Yada Yada" );
> Questions:
> *	Am I mis-understanding NDC usage somehow?
> *	Am I doing something obviously wrong in the code?
> *	Am I hitting a bug in my combination of appenders (or my
> usage/configuration of them)?
> Again -- this is intermittent, I can't quite track down what causes it &
> when exactly it happens. Any insights appreciated.
> regards
> Adam
> --
> Open Business Interchange: <http://www.openbiz.biz>
> The Revolutionary B2Bi Web Service ...

To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>

View raw message