commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rathert Jonas (Platinion)" <>
Subject Problem understanding commons-logging default factory
Date Wed, 18 Dec 2002 12:44:29 GMT
Hi there,

I just started using log4j and commons-logging (I use 
commons-logging-1.0.2 and log4j-1.2.7) and am now stuck
with a small problem (well, it's not really a serious problem, 
but I'm curious...).

I have a file which is found at startup
of my program (this was validated by specifiying a different 
LogFactory to use JLEA [] - which works).

Now, from what I understand, if I do not specify any particular 
LogFactory in that file, commons-logging will choose 


as the default factory.  If I include the log4j JAR files in 
my project (and configure log4j the right way), log4j is used 
and works perfectly.

But then I started playing around with the 


property.  The documentation of the default factory says:

  "When a new Log instance must be created, the default LogFactory 
   implementation uses the following discovery process is used:

    * Look for a system property named 
        org.apache.commons.logging.Log [...]
    * Look for a configuration attribute of this factory named 
    * If the Log4J logging system is available in the application 
        class path, use the corresponding wrapper class 

Following this, I tried to override the use of log4j by putting 
the following line into my


No I would expect the log output to disappear (as NoOpLog just throws
away everything).  But this only happens, if I remove the log4j jar from 
my project - otherwise, still log4j is used (and the Log-property above
seems to be ignored).

Even if I define this as a system-property in my java call:

  java -Dorg.apache.commons.logging.Log=\
    org.apache.commons.logging.impl.NoOpLog ...

the behaviour is as described above: Still,log4j is used.

Is this the expected behavior (if log4j is available, always use it in
favor of all "SimpleLog" or "NoOpLog" implementations - so the docs are 
wrong here!), or did I read the wrong part of the docs? Or did I do 
any other mistake?

(Actually, I'll never use SimpleLog or NoOpLog, so it's more a 
academical kind of question, but as I said: I'm just curious. :-)

Thanks in advance


    Jonas Rathert | IT Architect

    A Company of the Boston Consulting Group

    Im Mediapark 5, 50670 Cologne/Germany
    Tel.    +49 221. 58 95 83 04,  Mobile    +49 160. 532 13 04
    Fax     +49 221. 589 20 51

View raw message