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.Log;
   21   import org.apache.log4j.ConsoleAppender;
   22   import org.apache.log4j.Level;
   23   import org.apache.log4j.Logger;
   24   import org.apache.log4j.PatternLayout;
   25   
   26   /**
   27    * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
   28    */
   29   public class BootstrapLog4jLog implements Log {
   30       static {
   31           Logger root = Logger.getRootLogger();
   32           root.addAppender(new ConsoleAppender(new PatternLayout("%d{ABSOLUTE} %-5p [%c{1}] %m%n")));
   33   
   34           GeronimoLogging level = GeronimoLogging.getDefaultLevel();
   35           if (level == null) {
   36               root.setLevel(Level.ERROR);
   37           } else if (level == GeronimoLogging.TRACE) {
   38               root.setLevel(Level.DEBUG);
   39           } else if (level == GeronimoLogging.DEBUG) {
   40               root.setLevel(Level.DEBUG);
   41           } else if (level == GeronimoLogging.INFO) {
   42               root.setLevel(Level.INFO);
   43           } else if (level == GeronimoLogging.WARN) {
   44               root.setLevel(Level.WARN);
   45           } else if (level == GeronimoLogging.ERROR) {
   46               root.setLevel(Level.ERROR);
   47           } else if (level == GeronimoLogging.FATAL) {
   48               root.setLevel(Level.FATAL);
   49           }
   50   
   51       }
   52   
   53       private static final String FQCN = BootstrapLog4jLog.class.getName();
   54       private Logger logger;
   55   
   56       public BootstrapLog4jLog(String name) {
   57           logger = Logger.getLogger(name);
   58       }
   59   
   60       public boolean isTraceEnabled() {
   61           return logger.isEnabledFor(Level.DEBUG);
   62       }
   63   
   64       public void trace(Object message) {
   65           logger.log(FQCN, Level.DEBUG, message, null);
   66       }
   67   
   68       public void trace(Object message, Throwable throwable) {
   69           logger.log(FQCN, Level.DEBUG, message, throwable);
   70       }
   71   
   72       public boolean isDebugEnabled() {
   73           return logger.isEnabledFor(Level.DEBUG);
   74       }
   75   
   76       public void debug(Object message) {
   77           logger.log(FQCN, Level.DEBUG, message, null);
   78       }
   79   
   80       public void debug(Object message, Throwable throwable) {
   81           logger.log(FQCN, Level.DEBUG, message, throwable);
   82       }
   83   
   84       public boolean isInfoEnabled() {
   85           return logger.isEnabledFor(Level.INFO);
   86       }
   87   
   88       public void info(Object message) {
   89           logger.log(FQCN, Level.INFO, message, null);
   90       }
   91   
   92       public void info(Object message, Throwable throwable) {
   93           logger.log(FQCN, Level.INFO, message, throwable);
   94       }
   95   
   96       public boolean isWarnEnabled() {
   97           return logger.isEnabledFor(Level.WARN);
   98       }
   99   
  100       public void warn(Object message) {
  101           logger.log(FQCN, Level.WARN, message, null);
  102       }
  103   
  104       public void warn(Object message, Throwable throwable) {
  105           logger.log(FQCN, Level.WARN, message, throwable);
  106       }
  107   
  108       public boolean isErrorEnabled() {
  109           return logger.isEnabledFor(Level.ERROR);
  110       }
  111   
  112       public void error(Object message) {
  113           logger.log(FQCN, Level.ERROR, message, null);
  114       }
  115   
  116       public void error(Object message, Throwable throwable) {
  117           logger.log(FQCN, Level.ERROR, message, throwable);
  118       }
  119   
  120       public boolean isFatalEnabled() {
  121           return logger.isEnabledFor(Level.FATAL);
  122       }
  123   
  124       public void fatal(Object message) {
  125           logger.log(FQCN, Level.FATAL, message, null);
  126       }
  127   
  128       public void fatal(Object message, Throwable throwable) {
  129           logger.log(FQCN, Level.FATAL, message, throwable);
  130       }
  131   }

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