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�" <[EMAIL PROTECTED]>
To: "LOG4J Users Mailing List" <[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:
[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