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 Bill Rebey <Bi...@quovadx.com> on 2002/02/15 19:21:44 UTC
Per-thread logging
I want to be able to set different Priorities and Formats for individual
threads.
Can I do this with a single Logger? If not, how might a I proceed?
I tried subclassing Thread and giving the subclass a Logger member, then
making a logging wrapper of sorts that gets the current thread and tries to
use the Logger in the subclassed thread, like this:
public class MyThread extends Thread
{
public Category thisThreadsLogger;
...
}
public class Log
{
public static void debug (String strMsg)
{
((MyThread)
MyThread.currentThread()).thisThreadsLogger.debug (strMsg);
}
}
But my "debug" method generates a ClassCastException when I try to cast the
Thread returned from "currentThread()"
to a MyThread.
How should I be handling this?
Bill Rebey
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>