Home » geronimo-2.2-source-release » org.apache.geronimo.kernel.log » [javadoc | source]

    1   /**
    2    *
    3    * Copyright 2003-2004 The Apache Software Foundation
    4    *
    5    *  Licensed under the Apache License, Version 2.0 (the "License");
    6    *  you may not use this file except in compliance with the License.
    7    *  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   
   18   package org.apache.geronimo.kernel.log;
   19   
   20   import org.apache.commons.logging.LogFactory;
   21   
   22   /**
   23    * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
   24    */
   25   public class GeronimoLogging {
   26       public static final GeronimoLogging TRACE = new GeronimoLogging("TRACE");
   27       public static final GeronimoLogging DEBUG = new GeronimoLogging("DEBUG");
   28       public static final GeronimoLogging INFO = new GeronimoLogging("INFO");
   29       public static final GeronimoLogging WARN = new GeronimoLogging("WARN");
   30       public static final GeronimoLogging ERROR = new GeronimoLogging("ERROR");
   31       public static final GeronimoLogging FATAL = new GeronimoLogging("FATAL");
   32   
   33       private static boolean initialized = false;
   34       private static GeronimoLogging defaultLevel;
   35   
   36       /**
   37        * Initializes the logging system used by Geronimo.  This MUST be called in
   38        * in the main class used to start the geronimo server.  This method forces
   39        * commons logging to use GeronimoLogFactory, starts the initial commons-logging
   40        * logging system, and forces mx4j to use commons logging.
   41        */
   42       public static void initialize(GeronimoLogging level) {
   43           if (!initialized) {
   44               defaultLevel = level;
   45   
   46               // force commons-logging to use our log factory
   47               System.setProperty(LogFactory.FACTORY_PROPERTY, GeronimoLogFactory.class.getName());
   48   
   49               // force the log factory to initialize
   50               LogFactory.getLog(GeronimoLogging.class);
   51   
   52               // force mx4j to use commons logging
   53               // todo do this with reflection so mx4j is not required (this is important in JDK 1.5)
   54               mx4j.log.Log.redirectTo(new mx4j.log.CommonsLogger());
   55   
   56               initialized = true;
   57           }
   58   
   59       }
   60   
   61       public static GeronimoLogging getDefaultLevel() {
   62           return defaultLevel;
   63       }
   64   
   65       private final String level;
   66   
   67       private GeronimoLogging(String level) {
   68           this.level = level;
   69       }
   70   
   71       public String toString() {
   72           return level;
   73       }
   74   
   75       public boolean equals(Object object) {
   76           return object == this;
   77       }
   78   }

Home » geronimo-2.2-source-release » org.apache.geronimo.kernel.log » [javadoc | source]