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 Keith Rogers <ke...@mouchelparkman.com> on 2005/03/05 14:34:33 UTC

ThreadName

I'm using log4j 1.2.8, and am having a problem with LoggingEvent's
getThreadName method - it is always returning the name of the thread
that I call the getThreadName method from, rather the name of the thread
that created the log event.

Having had a look at the source, it seems to me that the threadName
field is not set in either of the constructors, so the getThreadName
method simply reverts to its null value behaviour - the name of the
calling thread.

I also noticed that while a timeStamp field is set in the constructors,
I can't find a corresponding getTimeStamp method.

I'm reasonably sure that I must be doing something wrong, or looking in
the wrong place... but can anyone help?

Thanks,

Keith


The information in this e-mail is confidential and intended to be solely for the use of the addressee(s) and may contain copyright and/or legally privileged information.  If you are not the addressee (or responsible for delivery of the message to the addressee) please e-mail us at Postmaster@mouchelparkman.com and delete the message from your computer; copying, distribution, use or disclosure of its contents is strictly prohibited.
As Internet communications are capable of data corruption no responsibility is accepted for changes made to this message after it was sent. For this reason it may be inappropriate to rely on advice contained in any e-mail without obtaining written confirmation of it.
In addition, no liability or responsibility is accepted for viruses and it is your responsibility to scan attachments (if any).
Please note that for business purposes, outgoing and incoming emails from and to the company may be monitored and recorded.

Mouchel Parkman Services Ltd, Registered in England at West Hall, Parvis Road, West Byfleet, Surrey UK KT14 6EZ Registered No : 1686040


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


Re: ThreadName

Posted by Curt Arnold <ca...@apache.org>.
On Mar 5, 2005, at 7:34 AM, Keith Rogers wrote:

> I'm using log4j 1.2.8, and am having a problem with LoggingEvent's
> getThreadName method - it is always returning the name of the thread
> that I call the getThreadName method from, rather the name of the 
> thread
> that created the log event.
>
> Having had a look at the source, it seems to me that the threadName
> field is not set in either of the constructors, so the getThreadName
> method simply reverts to its null value behaviour - the name of the
> calling thread.
>
> I also noticed that while a timeStamp field is set in the constructors,
> I can't find a corresponding getTimeStamp method.
>
> I'm reasonably sure that I must be doing something wrong, or looking in
> the wrong place... but can anyone help?
>

Sorry I don't have the 1.2.x series around, but I think the concepts 
are the same.  The assumption is that a LoggingEvent is "rendered" 
before being made accessible to another thread (or serialized) etc.  In 
1.3, this is done by LoggingEvent.prepareForDeferredProcessing which is 
called, for example, in AsyncAppender.doAppend before placing the event 
in the queue.  That method is marked as a 1.3 method, but there should 
be a 1.2 predecessor.  The idea was to avoid the cost of "rendering" 
the thread name until it was requested in synchronous processing or 
just before the information became unavailable.


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


Re: ThreadName

Posted by Fred McCann <fr...@automaticrootbeer.com>.
I noticed the same behavior with thread name while writing a custom 
appender. The work around I found was to call getThreadName() in the 
doAppend() method. That appeared to set the correct thread name. This 
seems like a bug to me.


-- Fred McCann

On Mar 5, 2005, at 8:34 AM, Keith Rogers wrote:

> I'm using log4j 1.2.8, and am having a problem with LoggingEvent's
> getThreadName method - it is always returning the name of the thread
> that I call the getThreadName method from, rather the name of the 
> thread
> that created the log event.
>
> Having had a look at the source, it seems to me that the threadName
> field is not set in either of the constructors, so the getThreadName
> method simply reverts to its null value behaviour - the name of the
> calling thread.
>
> I also noticed that while a timeStamp field is set in the constructors,
> I can't find a corresponding getTimeStamp method.
>
> I'm reasonably sure that I must be doing something wrong, or looking in
> the wrong place... but can anyone help?
>
> Thanks,
>
> Keith
>
>
> The information in this e-mail is confidential and intended to be 
> solely for the use of the addressee(s) and may contain copyright 
> and/or legally privileged information.  If you are not the addressee 
> (or responsible for delivery of the message to the addressee) please 
> e-mail us at Postmaster@mouchelparkman.com and delete the message from 
> your computer; copying, distribution, use or disclosure of its 
> contents is strictly prohibited.
> As Internet communications are capable of data corruption no 
> responsibility is accepted for changes made to this message after it 
> was sent. For this reason it may be inappropriate to rely on advice 
> contained in any e-mail without obtaining written confirmation of it.
> In addition, no liability or responsibility is accepted for viruses 
> and it is your responsibility to scan attachments (if any).
> Please note that for business purposes, outgoing and incoming emails 
> from and to the company may be monitored and recorded.
>
> Mouchel Parkman Services Ltd, Registered in England at West Hall, 
> Parvis Road, West Byfleet, Surrey UK KT14 6EZ Registered No : 1686040
>
>
> ---------------------------------------------------------------------
> 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