Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 96857 invoked from network); 16 Dec 2004 05:06:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 16 Dec 2004 05:06:04 -0000 Received: (qmail 81795 invoked by uid 500); 16 Dec 2004 05:05:59 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 81776 invoked by uid 500); 16 Dec 2004 05:05:58 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 81759 invoked by uid 99); 16 Dec 2004 05:05:58 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of jak-commons-dev@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from main.gmane.org (HELO main.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 15 Dec 2004 21:05:21 -0800 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CenpG-0004H4-00 for ; Thu, 16 Dec 2004 06:05:18 +0100 Received: from pool-68-239-103-73.res.east.verizon.net ([68.239.103.73]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 Dec 2004 06:05:17 +0100 Received: from sgarlatm by pool-68-239-103-73.res.east.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 Dec 2004 06:05:17 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: commons-dev@jakarta.apache.org From: Matt Sgarlata Subject: Re: [logging] Enterprise Common Logging... dare we say 2.0? Date: Thu, 16 Dec 2004 00:04:57 -0500 Lines: 88 Message-ID: References: <1103156615.3684.23.camel@blackbox> <1103170723.3684.44.camel@blackbox> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pool-68-239-103-73.res.east.verizon.net User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en In-Reply-To: <1103170723.3684.44.camel@blackbox> Sender: news X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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 commons-logging.properties 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 commons-logging.properties 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 commons-logging.properties 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 commons-logging.properties 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. http://java.sun.com/j2se/1.4.2/docs/api/java/beans/PropertyEditorManager.html > Regards, > > Simon Matt --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org