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();   
    }
    ...
 }

Thus, the thread field will always have the correct value. Nice try though. :-)
I am looking forward for the ThreadAppender. Cheers, Ceki

At 20:06 14.06.2001 -0400, you wrote:
>The thread name is part of the LoggingEvent, though 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.
>
>I'll try to hack-out a ThreadAppender, though...
>
>-Jim Moore
>
>-----Original Message-----
>From: James House [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, June 14, 2001 7:43 PM
>To: LOG4J Users Mailing List
>Subject: Re: Do I need to use multiple hierarchies, and how?
>
>
>
>What about making a new appender that contains a collection of appenders - 
>each keyed with a name.
>
>When the appender is told to log something, it can look at which thread is 
>doing the logging, and use the thread's name as the key to retrieve the 
>appropriate file appender, which it then delegates the work to?  -- if you 
>had the Async.Appender in front though, that would screw up the thread name 
>(since it has it's own thread), so maybe you'd have to pass something in 
>the log message that can be extracted and used as the key.....
>
>-- granted this is a bit of work...
>
>
>At 6/14/2001 04:32 PM -0700, you wrote:
>>Wouldn't the easiest way to accomplish this is create Category and 
>>Appender for each new Thread as it enters the pool (where the name of the 
>>category and appender are the unique thread identifier assigned in the 
>>constructor):
>>
>>
>>Thread t = new Thread(xxxSomeRunnablexxx,"xxxSome Thread Id");
>>Category cat = Category.getInstance("xxxSomeRunnablexxx");
>>FileAppender appender = new FileAppender(xxxSomeLayoutxxx,"xxxSome Thread 
>>Id"+".log");
>>cat.addAppender(appender);
>>
>>And then from within the thread:
>>
>>Thread t = Thread.currentThread();
>>Category cat = t.getInstance(t.getName());
>>cat.ERROR(xxx); // or whatever
>>
>>
>>That would probably be the easiest way to do this without making changes 
>>to Log4J.
>>
>>-Chris
>>----- Original Message -----
>>From: "Ceki Gülcü" <<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]>
>>To: "LOG4J Users Mailing List" 
>><<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]>
>>Sent: Thursday, June 14, 2001 3:56 PM
>>Subject: RE: Do I need to use multiple hierarchies, and how?
>>
>>
>>Jim,
>>
>>No actually not. I had not fully read the question previously. I don't 
>>think log4j is designed for thread based logging. This had never come up 
>>before. Regards, Ceki
>>
>>At 17:54 14.06.2001 -0400, Jim Moore wrote:
>> >Is multiple hierarchies the most appropriate way of doing this?
>> >
>> >
>> >-----Original Message-----
>> >From: Ceki Gülcü [mailto:[EMAIL PROTECTED]]
>> >Sent: Thursday, June 14, 2001 4:56 PM
>> >To: LOG4J Users Mailing List
>> >Subject: Re: Do I need to use multiple hierarchies, and how?
>> >
>> >
>> >
>> >Jim,
>> >
>> >Look a the SocketServer for an example of using different hierarchies.
>You
>> >have understand the rest of log4j pretty well before you use multiple
>> >hierarchies. Otherwise, it's pretty straightforward. Regards, Ceki
>> >
>> >At 15:21 14.06.2001 -0400, you wrote:
>> >>> Hi,
>> >>>
>> >>>   I apologize, in advance, if this question has already been answered.
>> >If
>> >>> it has, please point me to the existing reply.  I am using worker
>threads
>> >>> in the same JVM and would like each thread to maintain its own log
>file.
>> >>> Other than that, I would like to use the same categories and layouts.
>> >>> Only the appenders would be thread specific.  Multiple hierarchies
>were
>> >>> mentioned in the introductory manual as an advanced topic.  Do
>multiple
>> >>> hierarchies make sense in this situation?  Is there an example of
>> >multiple
>> >>> hierarchy usage?  Is there more documentation on this topic?
>> >>>
>> >>> Thank You,
>> >>> Jim Prokash
>> >
>> >--
>> >Ceki Gülcü
>> >
>> >---------------------------------------------------------------------
>> >To unsubscribe, e-mail: 
>>
><mailto:[EMAIL PROTECTED]>log4j-user-unsubscribe@jak
>arta.apache.org
>> >For additional commands, e-mail: 
>>
><mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
>g
>>
>>--
>>Ceki Gülcü
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: 
>><mailto:[EMAIL PROTECTED]>log4j-user-unsubscribe@ja
>karta.apache.org
>>For additional commands, e-mail: 
>><mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
>rg
>
>
>---------------------------------------------------------------------
>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]

--
Ceki Gülcü


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

Reply via email to