Home | History | Annotate | Download | only in log4j
      1 /*
      2  * Copyright 2001-2004 The Apache Software Foundation.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package org.apache.log4j;
     18 
     19 import org.apache.log4j.spi.LoggerFactory;
     20 import org.slf4j.spi.LocationAwareLogger;
     21 
     22 /**
     23  * <p>
     24  * This class is a minimal implementation of the original
     25  * <code>org.apache.log4j.Logger</code> class (as found in log4j 1.2)
     26  * delegating all calls to a {@link org.slf4j.Logger} instance.
     27  * </p>
     28  *
     29  * @author Ceki G&uuml;lc&uuml;
     30  * */
     31 @SuppressWarnings("rawtypes")
     32 public class Logger extends Category {
     33 
     34     private static final String LOGGER_FQCN = Logger.class.getName();
     35 
     36     protected Logger(String name) {
     37         super(name);
     38     }
     39 
     40     public static Logger getLogger(String name) {
     41         return Log4jLoggerFactory.getLogger(name);
     42     }
     43 
     44     public static Logger getLogger(String name, LoggerFactory loggerFactory) {
     45         return Log4jLoggerFactory.getLogger(name, loggerFactory);
     46     }
     47 
     48     public static Logger getLogger(Class clazz) {
     49         return getLogger(clazz.getName());
     50     }
     51 
     52     /**
     53      * Does the obvious.
     54      *
     55      * @return
     56      */
     57     public static Logger getRootLogger() {
     58         return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
     59     }
     60 
     61     /**
     62      * Delegates to {@link org.slf4j.Logger#isTraceEnabled}
     63      * method of SLF4J.
     64      */
     65     public boolean isTraceEnabled() {
     66         return slf4jLogger.isTraceEnabled();
     67     }
     68 
     69     /**
     70      * Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J.
     71      */
     72     public void trace(Object message) {
     73         differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
     74     }
     75 
     76     /**
     77      * Delegates to {@link org.slf4j.Logger#trace(String,Throwable)}
     78      * method in SLF4J.
     79      */
     80     public void trace(Object message, Throwable t) {
     81         differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
     82     }
     83 
     84 }
     85