logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Rebey <Bill.Re...@quovadx.com>
Subject Per-thread logging
Date Fri, 15 Feb 2002 18:21:44 GMT
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:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message