You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2003/08/11 23:04:56 UTC

cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/core/log Log4jLog.java XLevel.java

dain        2003/08/11 14:04:56

  Modified:    modules/core/src/conf log4j.properties
               modules/core/src/java/org/apache/geronimo Main.java
  Added:       modules/core/src/java/org/apache/geronimo/core/log
                        Log4jLog.java XLevel.java
  Log:
  Added a new implementation of Commons Logging log which implemnts the trace level.
  
  Revision  Changes    Path
  1.2       +2 -1      incubator-geronimo/modules/core/src/conf/log4j.properties
  
  Index: log4j.properties
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/conf/log4j.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- log4j.properties	11 Aug 2003 17:59:08 -0000	1.1
  +++ log4j.properties	11 Aug 2003 21:04:55 -0000	1.2
  @@ -1,6 +1,7 @@
  -log4j.rootCategory=DEBUG, CONSOLE
  +log4j.rootCategory=TRACE#org.apache.geronimo.core.log.XLevel, CONSOLE
   
   log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
  +#log4j.appender.CONSOLE.Threshold=TRACE#org.apache.geronimo.core.log.XLevel
   log4j.appender.CONSOLE.Threshold=DEBUG
   log4j.appender.CONSOLE.Target=System.out
   log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
  
  
  
  1.4       +12 -3     incubator-geronimo/modules/core/src/java/org/apache/geronimo/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/Main.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Main.java	11 Aug 2003 17:59:09 -0000	1.3
  +++ Main.java	11 Aug 2003 21:04:56 -0000	1.4
  @@ -59,6 +59,7 @@
   import java.net.URL;
   import java.util.Iterator;
   import java.util.Set;
  +import java.util.Properties;
   import javax.management.MBeanServer;
   import javax.management.MBeanServerFactory;
   import javax.management.ObjectInstance;
  @@ -66,7 +67,9 @@
   import javax.management.loading.MLet;
   
   import org.apache.geronimo.deployment.DeploymentException;
  -import org.apache.log4j.Logger;
  +import org.apache.commons.logging.LogFactory;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.impl.LogFactoryImpl;
   
   /**
    *
  @@ -75,7 +78,13 @@
    * @version $Revision$ $Date$
    */
   public class Main implements Runnable {
  -    private static final Logger log = Logger.getLogger("Geronimo");
  +    static {
  +        // Add our default Commons Logger that support the trace level
  +        if(System.getProperty(LogFactoryImpl.LOG_PROPERTY) == null) {
  +            System.setProperty(LogFactoryImpl.LOG_PROPERTY, "org.apache.geronimo.core.log.Log4jLog");
  +        }
  +    }
  +    private static final Log log = LogFactory.getLog("Geronimo");
       private static final String[] DEPLOY_ARG_TYPES = {"java.net.URL"};
   
       private final String domainName;
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/core/log/Log4jLog.java
  
  Index: Log4jLog.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" 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",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.core.log;
  
  import org.apache.commons.logging.Log;
  import org.apache.log4j.Logger;
  import org.apache.log4j.Priority;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2003/08/11 21:04:56 $
   */
  public class Log4jLog implements Log {
      private String FQCN = getClass().getName();
      private Logger logger;
  
      public Log4jLog() {
      }
  
      public Log4jLog(String name) {
          logger = Logger.getLogger(name);
      }
  
      public Log4jLog(Logger logger) {
          this.logger = logger;
      }
  
      public boolean isTraceEnabled() {
          return logger.isEnabledFor(XLevel.TRACE);
      }
  
      public void trace(Object message) {
          logger.log(FQCN, XLevel.TRACE, message, null);
      }
  
      public void trace(Object message, Throwable throwable) {
          logger.log(FQCN, XLevel.TRACE, message, throwable);
      }
  
      public boolean isDebugEnabled() {
          return logger.isDebugEnabled();
      }
  
      public void debug(Object message) {
          logger.log(FQCN, Priority.DEBUG, message, null);
      }
  
      public void debug(Object message, Throwable throwable) {
          logger.log(FQCN, Priority.DEBUG, message, throwable);
      }
  
      public boolean isInfoEnabled() {
          return logger.isInfoEnabled();
      }
  
      public void info(Object message) {
          logger.log(FQCN, Priority.INFO, message, null);
      }
  
      public void info(Object message, Throwable throwable) {
          logger.log(FQCN, Priority.INFO, message, throwable);
      }
  
      public boolean isWarnEnabled() {
          return true;
      }
  
      public void warn(Object message) {
          logger.log(FQCN, Priority.WARN, message, null);
      }
  
      public void warn(Object message, Throwable throwable) {
          logger.log(FQCN, Priority.WARN, message, throwable);
      }
  
      public boolean isErrorEnabled() {
          return true;
      }
  
      public void error(Object message) {
          logger.log(FQCN, Priority.ERROR, message, null);
      }
  
      public void error(Object message, Throwable throwable) {
          logger.log(FQCN, Priority.ERROR, message, throwable);
      }
  
      public boolean isFatalEnabled() {
          return true;
      }
  
      public void fatal(Object message) {
          logger.log(FQCN, Priority.FATAL, message, null);
      }
  
      public void fatal(Object message, Throwable throwable) {
          logger.log(FQCN, Priority.FATAL, message, throwable);
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/core/log/XLevel.java
  
  Index: XLevel.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" 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",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.core.log;
  
  import org.apache.log4j.Level;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2003/08/11 21:04:56 $
   */
  public final class XLevel extends Level {
      public static final int TRACE_INT = Level.DEBUG_INT - 1;
      private static String TRACE_NAME = "TRACE";
  
      /**
       * The Log4j Level Object to use for trace level messages
       */
      public static final XLevel TRACE = new XLevel(TRACE_INT, TRACE_NAME, 7);
  
      protected XLevel(int level, String name, int syslogEquiv) {
          super(level, name, syslogEquiv);
      }
  
      /**
       * Convert the String argument to a level. If the conversion
       * fails then this method returns {@link #TRACE}.
       */
      public static Level toLevel(String name) {
          return toLevel(name, XLevel.TRACE);
      }
  
      /**
       * Convert the String argument to a level. If the conversion
       * fails, return the level specified by the second argument,
       * i.e. defaultValue.
       */
      public static Level toLevel(String name, Level defaultValue) {
          if (name == null) {
              return defaultValue;
          }
          if (name.toUpperCase().equals(TRACE_NAME)) {
              return XLevel.TRACE;
          }
          return Level.toLevel(name, defaultValue);
      }
  
      /**
       * Convert an integer passed as argument to a level. If the
       * conversion fails, then this method returns {@link #DEBUG}.
       */
      public static Level toLevel(int level) throws IllegalArgumentException {
          if (level == TRACE_INT) {
              return XLevel.TRACE;
          } else {
              return Level.toLevel(level);
          }
      }
  }