Might be worthwhile making it optional whether to fill in thread name
with AsyncAppender as it's not always needed. Or else, I suppose, it
could be clever and figure it out itself from the configured layout.

Anders


Ceki Gülcü wrote:
> 
> Jim,
> 
> That's true but in AsyncAppender:
> 
> public
> void append(LoggingEvent event) {
>   // Set the NDC and thread name for the calling thread as these
>   // LoggingEvent fields were not set at event creation time.
>   event.getNDC();
>   event.getThreadName();
>   if(locationInfo) {
>     event.getLocationInformation();
>   }
>   ...
>  }
> 
> Fetching the current thread takes a few milliseconds compared to a mehtod call which 
>takes a few dozen nanoseconds. The idea is to avoid the cost of Thread.currentThread 
>if it is not required. Hence the lazy fill in of the thread name field. In 
>AsyncAppender we can no longer rely on being in the same thread so it gets filled in 
>at the start of AsyncAppender.doAppend. Hope this clarifies the issue. Ceki
> 
> At 19:31 14.06.2001 -0500, Jim Moore wrote:
> >As was just brought out on the Users list, the thread name is part of the
> >LoggingEvent, but the current implementation is:
> >  public String getThreadName() {
> >    if(threadName == null)
> >      threadName = (Thread.currentThread()).getName();
> >    return threadName;
> >  }
> >so if it's not asked for that information until it's in an AsyncAppender (or
> >having been serialized to a server) then it will give the wrong name.
> >
> >Any reason for threadName to not get set at LoggingEvent creation?
> >
> >-Jim Moore
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> 
> --
> Ceki Gülcü
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

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

Reply via email to