Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 18320 invoked from network); 1 May 2003 22:22:22 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 1 May 2003 22:22:22 -0000 Received: (qmail 14356 invoked by uid 97); 1 May 2003 22:24:28 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 14348 invoked from network); 1 May 2003 22:24:27 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 1 May 2003 22:24:27 -0000 Received: (qmail 18110 invoked by uid 500); 1 May 2003 22:22:20 -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 18094 invoked from network); 1 May 2003 22:22:19 -0000 Received: from mail.hot.ee (HELO hot.ee) (194.126.101.94) by daedalus.apache.org with SMTP; 1 May 2003 22:22:19 -0000 Received: from localhost (relay4 [127.0.0.1]) by hot.ee (Postfix) with ESMTP id 31EB5DCC for ; Fri, 2 May 2003 01:22:25 +0300 (EEST) Received: from hot.ee ([127.0.0.1]) by localhost (relay4 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 16996-19 for ; Fri, 2 May 2003 01:22:24 +0300 (EEST) Received: from apache.org (80-235-114-8-dsl.kt.estpak.ee [80.235.114.8]) by hot.ee (Postfix) with ESMTP id BAD7CDCE for ; Fri, 2 May 2003 01:22:23 +0300 (EEST) Message-ID: <3EB19E18.7020809@apache.org> Date: Fri, 02 May 2003 01:22:16 +0300 From: Neeme Praks User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; et-EE; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: [logging] commons logging API implementation, delegating to avalon framework logging API Content-Type: multipart/mixed; boundary="------------090505060301080608080408" X-Virus-Scanned: by mail.hot.ee X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --------------090505060301080608080408 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit As part of beefing up the jelly service for avalon, I wrote a dead-simple wrapper for avalon logging API to be plugged into commons logging (see the attachment). I'm not sure if this has been done before, but it was so easy to implement, so I didn't bother to search very hard. The usage, 2 lines of code, should be executed before loading any class that uses commons logging: AvalonLogger.setDefaultLogger(getLogger()); //static method, for passing the root logger. it is evil, but it seems to be the only workaround for now System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.jelly.avalon.AvalonLogger"); (the package name should probably be renamed) Anyway, the question is: where should this go? The most obvious answer seems to be commons-logging, right? Or some other ideas? Rgds, Neeme --------------090505060301080608080408 Content-Type: text/plain; name="AvalonLogger.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="AvalonLogger.java" /* * /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/avalon/src/java/org/apache/commons/jelly/avalon/JellyService.java,v 1.1 2003/01/22 09:19:30 jstrachan Exp * 1.1 * 2003/01/22 09:19:30 * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . * * JellyServiceImpl.java,v 1.1 2003/01/22 09:19:30 jstrachan Exp */ package org.apache.commons.jelly.avalon; import org.apache.avalon.framework.logger.Logger; import org.apache.commons.logging.Log; /** * Implementation of commons-logging Log interface that delegates all * logging calls to Avalon logging abstraction: the Logger interface. * * @author Neeme Praks */ public class AvalonLogger implements Log { private static Logger defaultLogger = null; private Logger logger = null; /** * @param logger the avalon logger implementation to delegate to */ public AvalonLogger(Logger logger) { this.logger = logger; } /** * @param logger the avalon logger implementation to delegate to */ public AvalonLogger(String name) { this.logger = defaultLogger.getChildLogger(name); } /** * @return avalon logger implementation */ public Logger getLogger() { return logger; } /** * @param logger the default avalon logger, in case there is no logger instance supplied in constructor */ public static void setDefaultLogger(Logger logger) { defaultLogger = logger; } /** * @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable) */ public void debug(Object o, Throwable t) { if (this.logger.isDebugEnabled()) this.logger.debug(o.toString(), t); } /** * @see org.apache.commons.logging.Log#debug(java.lang.Object) */ public void debug(Object o) { if (this.logger.isDebugEnabled()) this.logger.debug(o.toString()); } /** * @see org.apache.commons.logging.Log#error(java.lang.Object, java.lang.Throwable) */ public void error(Object o, Throwable t) { if (this.logger.isErrorEnabled()) this.logger.error(o.toString(), t); } /** * @see org.apache.commons.logging.Log#error(java.lang.Object) */ public void error(Object o) { if (this.logger.isErrorEnabled()) this.logger.error(o.toString()); } /** * @see org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable) */ public void fatal(Object o, Throwable t) { if (this.logger.isFatalErrorEnabled()) this.logger.fatalError(o.toString(), t); } /** * @see org.apache.commons.logging.Log#fatal(java.lang.Object) */ public void fatal(Object o) { if (this.logger.isFatalErrorEnabled()) this.logger.fatalError(o.toString()); } /** * @see org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable) */ public void info(Object o, Throwable t) { if (this.logger.isInfoEnabled()) this.logger.info(o.toString(), t); } /** * @see org.apache.commons.logging.Log#info(java.lang.Object) */ public void info(Object o) { if (this.logger.isInfoEnabled()) this.logger.info(o.toString()); } /** * @see org.apache.commons.logging.Log#isDebugEnabled() */ public boolean isDebugEnabled() { return this.logger.isDebugEnabled(); } /** * @see org.apache.commons.logging.Log#isErrorEnabled() */ public boolean isErrorEnabled() { return this.logger.isErrorEnabled(); } /** * @see org.apache.commons.logging.Log#isFatalEnabled() */ public boolean isFatalEnabled() { return this.logger.isFatalErrorEnabled(); } /** * @see org.apache.commons.logging.Log#isInfoEnabled() */ public boolean isInfoEnabled() { return this.logger.isInfoEnabled(); } /** * @see org.apache.commons.logging.Log#isTraceEnabled() */ public boolean isTraceEnabled() { return this.logger.isDebugEnabled(); } /** * @see org.apache.commons.logging.Log#isWarnEnabled() */ public boolean isWarnEnabled() { return this.logger.isWarnEnabled(); } /** * @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable) */ public void trace(Object o, Throwable t) { if (this.logger.isDebugEnabled()) this.logger.debug(o.toString(), t); } /** * @see org.apache.commons.logging.Log#trace(java.lang.Object) */ public void trace(Object o) { if (this.logger.isDebugEnabled()) this.logger.debug(o.toString()); } /** * @see org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable) */ public void warn(Object o, Throwable t) { if (this.logger.isWarnEnabled()) this.logger.warn(o.toString(), t); } /** * @see org.apache.commons.logging.Log#warn(java.lang.Object) */ public void warn(Object o) { if (this.logger.isWarnEnabled()) this.logger.warn(o.toString()); } } --------------090505060301080608080408 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org --------------090505060301080608080408--