commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <skitch...@apache.org>
Subject RE: commons-logging discovery process
Date Wed, 08 Mar 2006 20:16:52 GMT
On Wed, 2006-03-08 at 15:11 +0100, Boris Unckel wrote:
> Hi,
> > Von: "Shai Wolf" <shai.wolf@coridan.com>
> > Generally, I understand what you're saying.
> > However, I still don't understand why commons-logging can't supply an
> > indication on whether it detected a logging implementation or not. This
> > indication should not be platform dependant, but it should be managed by
> > the commons-logging layer only.
> no thats not correct. It could offer an indication if it has detected a
> logging implementation. It detects classloader issues already.
> But it cannot offer an indicator wheter the underlying log API is properly
> configured or not. So the indicator would be JCL specific and not give a
> hint about the full chain.
> 

I agree with Boris' comments.

Note though that when commons-logging's "auto-detect" feature is used,
it *always* detects a logging implementation of some kind; the SimpleLog
implementation is included in commons-logging.jar and is "discovered" if
nothing else is available.

What you are asking (as Boris noted) is for information about whether
the implementation used by commons-logging (whether discovered or
explicitly specified) correctly managed to auto-configure itself. That's
not generally information that underlying logging libraries make
available. As far as I know, log4j's API doesn't provide any mechanism
for detecting that, nor java.util.logging.

In any case, the commons-logging documentation makes clear that
commons-logging does *not* set up or shut down logging libraries; that's
NOT within the scope of the project. The fact that most logging
libraries do auto-configure themselves is a bonus. However in
*principle* your code is required to initialise whatever concrete
logging library is available before any calls to commons-logging APIs
are made. As you appear to *know* that log4j is the library in use,
there's nothing stopping you explicitly configuring (and testing) log4j
in your startup code, before any commons-logging calls are made.

Note also that auto-detect is not always the best option; placing a
commons-logging.properties file in the classpath which specifies which
underlying library to use is more reliable and recommended whenever you
*know* what lib you want to use. As you know log4j is available, a
commons-logging.properties file that specifies
  org.apache.commons.logging.Log =
    org.apache.commons.logging.impl.Log4JLogger
to bypass auto-detect would also be a good idea.

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message