commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Sgarlata <>
Subject Re: [logging] Enterprise Common Logging... dare we say 2.0?
Date Thu, 16 Dec 2004 05:04:57 GMT
Response below...

Simon Kitching wrote:
> On Thu, 2004-12-16 at 13:53, Matt Sgarlata wrote:
>>Simon Kitching wrote:
>>>I think this demonstrates a major issue.
>>>When using logging in an "enterprise" situation, the logging can be
>>>considered a critical part of the application. If you have heavy-duty
>>>monitoring systems watching for alerts from the software, and have
>>>sysadmins on call 24x7 to deal with issues, then for an application to
>>>fail to locate the correct logging libs or config files is a *failure*
>>>of the app. You don't want an app to start up, but then not be able to
>>>generate alerts if problems occur.
>>>But when using logging in other situations, logging is *not* a critical
>>>part, and should not cause an application to fail to start.
>>>The latter is the focus of commons-logging at the moment. And
>>>unfortunately as commons-logging has no *mandatory* configuration, it is
>>>not possible to add a "fail-on-no-config" option!
>>>So perhaps we could build two separate jars from mostly-common source
>>>code? Deploying the traditional commons-logging jar would do the "be
>>>quiet on no config", while the "enterprise" commons-logging jar would do
>>>something like "write message to STDERR then throw a runtime exception
>>>on no config"?
>>Why not just introduce a boolean parameter that says whether or not an 
>>inability to log is a failure?  e.g.
>>Log log = LogFactory.getLog(MyClass.class, true);
> It's not "inability to log" as such. It's whether finding no specific
> config info or underlying log implementation and therefore falling back
> to using java.util.logging (java>=1.4) or
> org.apache.commons.logging.SimpleLog (java<1.4) is allowed or not.
> In many cases, what you *want* an app to do if it can't find any
> specific logging config is simply to output ERROR and FATAL messages to
> stderr. This is what commons-logging will currently do if its
> "discovery" process finds nothing.
> I guess commons-logging *could* use a parameter such as you suggest to
> indicate "explicit configuration of logging is mandatory". This would
> presumably mean detecting whether or the
> corresponding system properties have defined an explicit log
> implementation and config file for that implementation.
> I'm not sure, however, if the decision on whether logging is mandatory
> or not should be a compile-time one. It seems to me to be more like
> something the application *deployer* should choose. That then leads us
> to a circular reference: how do we know whether configuration is
> mandatory or not, if we can't find any configuration?

Ah-hah, I see what you're getting at.

I have an idea... All logging implementations for Java configure logging 
by package, right?  What if we allow component developers to include 
their own that's not at the root of the 
source tree?  For example, if Morph suddenly decided it was very 
important to have certain messages logged, I just drop a in net.sf.morph that specifies the logging 
settings for net.sf.morph and all subpackages (e.g. which log factory to 
use, whether my messages *must* be heard, etc).  If JCL detects such a 
file it ensure the component that the logging it specifies is happening. 
  If an application developer, assembler or deployer decides later that 
Morph really isn't as important as I'd like, then they just delete the or put their own version in the 
WEB-INF/classes directory.  (Forgive me if this is a great show of my 
ignorance of classloading, but I think this is at least how things work 
for Tomcat).

Searching for a file like this on the classpath would certainly have 
performance implications.  However, search cost is incurred only on 
startup and there is precedent (see below), so it can't be too bad. 
It's certainly worth a try.

> Regards,
> Simon


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

View raw message