commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: [Commons-Logging] Using Commons-Logging with an older Log4J ( 1.1.3 )
Date Tue, 03 Jun 2003 15:32:46 GMT


On Tue, 3 Jun 2003, Jesus M. Salvo Jr. wrote:

> Date: Tue, 03 Jun 2003 17:52:53 +1000
> From: Jesus M. Salvo Jr. <jesus.salvo@migasia.com>
> Reply-To: Jakarta Commons Users List <commons-user@jakarta.apache.org>
> To: commons-user@jakarta.apache.org
> Subject: [Commons-Logging] Using Commons-Logging with an older Log4J (
>     1.1.3 )
>
>
> I am using Commons-Logging against Log4J 1.1.3
>
> I use Commons-Logging like this:
>
> *) via System properties:
> -Dlog4j.configuration=/export/softgame/app_gateway/prod/test/log4j.properties
> -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JCategoryLog
>
> *) within source code:
>     Log     logger = LogFactory.getLog( "SMimeFetcher" );
>
> I presume that the String passed in becomes the category name in Log4J.
> The calls to info() does get outputted via Log4J, ... but they all get
> logged to Log4J's root category!
>
> Interestingly though, I looked at the source code for
> org.apache.commons.logging.impl.Log4JCategoryLog, and there is no
> reference to Log4J's Category class, but instead it references Log4J's
> Logger class.
>
> However, Log4J 1.1.3 did not yet have Log4J's Logger class. In short, I
> would have expected it to NOT work, but it still did.
>

Direct calls to Log4J will, of course, work fine as long as you use Log4J
1.1 compatible APIs.  But for the commons-logging wrappers, this depends
on your definition of "works".  Commons Logging decides whether
Log4J is available by looking for the existence of the
org.apache.log4j.Logger class in the class path available to your
application.  If it's not there (as would be true in your case), Commons
Logging will simply assume that Log4J is not available, and default to JDK
1.4 logging (if you're using JDK 1.4) or SimpleLog (if you're not).

>
> Anyway ... is there any other alternative to reliably using
> Commons-Logging against Log4J apart from upgrading to the latest Log4J?
>

The Commons-Logging integrated support for Log4J requires Log4J 1.2 or
later.

Craig

Mime
View raw message