You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gregory Gray <gr...@future-skies.com> on 2002/03/28 23:42:21 UTC

Is there a way to use a Level subclass value in a configuration file?

My goal is for my code to not care if I'm using Log4j's logger or the
logger from Java 1.4.  Even though I'm planning to use Log4j, I want to
be able to change without altering the debugging statements if need be.
It's also key to be able to change the level in the configuration file
on the fly to alter the debugging behavior since restarting the
application is really not an option in the field.

If I use logger.log(Level, message) the same code can use either
library.  The problem is that the levels don't match up (except for ALL
and INFO).  To allow more levels I created MyLevel (based it on the
XLevel example) to include MyLevel.FINE, MyLevel.FINER, and
MyLevel.FINEST.  This works if I code in the setting of the level
(logger.setLevel(MyLevel.FINER)) but it does not pick it up from my
configuration file since the configuration file reader does not know
about the MyLevel subclass.  Is there a way to specify this that I'm
missing?  If not it would be nice to have an attribute in the config
file to allow you to identify a different Level implementation to use.

I searched through the mailing list archives for information about this
but did not find anything.  I apologize if I'm repeating an old
discussion.

Thanks for you attention!

-Greg


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Is there a way to use a Level subclass value in a configuration file?

Posted by Gregory Gray <gr...@future-skies.com>.
I read the dtd for configuration files more carefully and saw that you
can specify the Level class when specifying the level.

		<level class="mypackage.MyLevel" value="FINER"/>

I figured I'd send the answer in case anyone was interested.

-Greg

-----Original Message-----
From: Gregory Gray [mailto:greg.gray@future-skies.com] 
Sent: Thursday, March 28, 2002 5:42 PM
To: 'Log4J Developers List'
Subject: Is there a way to use a Level subclass value in a configuration
file?


My goal is for my code to not care if I'm using Log4j's logger or the
logger from Java 1.4.  Even though I'm planning to use Log4j, I want to
be able to change without altering the debugging statements if need be.
It's also key to be able to change the level in the configuration file
on the fly to alter the debugging behavior since restarting the
application is really not an option in the field.

If I use logger.log(Level, message) the same code can use either
library.  The problem is that the levels don't match up (except for ALL
and INFO).  To allow more levels I created MyLevel (based it on the
XLevel example) to include MyLevel.FINE, MyLevel.FINER, and
MyLevel.FINEST.  This works if I code in the setting of the level
(logger.setLevel(MyLevel.FINER)) but it does not pick it up from my
configuration file since the configuration file reader does not know
about the MyLevel subclass.  Is there a way to specify this that I'm
missing?  If not it would be nice to have an attribute in the config
file to allow you to identify a different Level implementation to use.

I searched through the mailing list archives for information about this
but did not find anything.  I apologize if I'm repeating an old
discussion.

Thanks for you attention!

-Greg


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>