Hi David,

How about subclassing the appender (eg FileAppender) class
to check the threadid against some table to determine the
destination to write the output to?

For example, if your threads are in different thread-groups, 
then the FileAppender could check it's threadgroup, and
output to a thread-group-related file. Or each thread be
registered as being part of a specific collection, eg call
ThreadRegister.getInstance().register("group1", threadid) 
on startup. This method would store the {threadid, groupid}
pair. The FileAppender subclass could then check
this table to decide where to write each message.

Of course, using thread ids means you can't use
AsyncAppender!

Regards,

Simon

> -----Original Message-----
> From: David Sanders [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, January 29, 2001 7:03 PM
> To:   'LOG4J Users Mailing List'
> Subject:      Multiple apps in same JVM
> 
> In order to run more app instances, e.g., HTTP load test clients, on a
> host,
> I often run multiple instances per machine.  For example, the app may
> instantiate 50 instances of a class, each in its own thread.
> 
> I need to distinguish the 50 instances in the log4j output.
> 
> - How can each app instance (w/i same JVM) go to a different appender,
> e.g.,
> file?  Does than a Category object for each of the 50 instances?
> 
> - Assume each of the 50 app instances spawns several threads, e.g., worker
> threads.  In order for each app instance's threads to log to the appender
> for that app instance, would the Category objects have to be passed (CTOR
> or
> setter) to each associated thread?
> 
> - Instead of an appender per app instance, NDC could be used.  But, all
> threads associated with an app instance's main thread would have to
> inherit
> NDC stack from spawning thread?
> 
> Thank you.
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to