logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <...@qos.ch>
Subject Re: thread name in LoggingEvent
Date Fri, 15 Jun 2001 07:43:18 GMT


That's true but in AsyncAppender:

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.
  if(locationInfo) {

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: log4j-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-dev-help@jakarta.apache.org

Ceki Gülcü

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

View raw message