commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: extending LogFactoryImpl
Date Tue, 14 Feb 2006 09:02:50 GMT
On Tue, 2006-02-14 at 14:44 +0800, sreenivas velagapudi wrote:
> Hi,
> I am using commons-logging and log4j
> My commons-logging .properties is as shown below,
> org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
> org.apache.commons.logging.Log=com.logging.log4j.Log4jAdapter
> I want to write one custom level called AUDIT in log4j
> The problem is, that the log level is hard coded into
> the method names of log interface of commons-logging
> You have "log.error, log.debug, " on the Log
> interface.

Commons-logging is not intended to be extended with additional log
levels. Commons-logging is meant to isolate code from the underlying
logging library, so it makes no sense to allow it to be extended to
handle custom logging levels that not all logging libraries support.

If you wish to use a custom log4j level, then I suggest your code use
log4j directly rather than using commons logging.

If you are absolutely determined to do this, then you don't need to
modify the LogFactoryImpl at all. You've already defined a custom Log
implementation and set up to point to it, so
you can just cast the result:

private static final Log4jAdapter log =
     (Log4jAdapter) LogFactory.getLog(ManagerImpl.class);

Of course this will throw an exception if you ever try to use it with
some other logging library, which makes it rather pointless. As I
suggested above, just use log4j directly.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message