Chris,
 
  I see a few issues with this solution.  I also thought of this, however.
 
     1. Each worker thread makes use of other shared objects.  Each of these "utility" objects have their own category.  If I were to use your suggestion, each "utility" object would have to create a thread unique category, which would cause a proliferation of categories. Instead of having a category per class, I would now have a category per class per thread.
 
     2. Since the thread ids are generated at runtime, there would be no way to configure the categories through a configuration file.
 
  I'm looking forward to the ThreadAppender that Jim Moore is working on.
 
Thanks for the feedback.
 
-Jim
-----Original Message-----
From: Christopher Taylor [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 14, 2001 7:33 PM
To: LOG4J Users Mailing List
Subject: Re: Do I need to use multiple hierarchies, and how?

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