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.slf4j.spi.LocationAwareLogger; 20 21 /** 22 * <p> 23 * This class is a minimal implementation of the original 24 * <code>org.apache.log4j.Logger</code> class (as found in log4j 1.2) 25 * delegating all calls to a {@link org.slf4j.Logger} instance. 26 * </p> 27 * 28 * @author Ceki Gülcü 29 * */ 30 public class Logger extends Category { 31 32 private static final String LOGGER_FQCN = Logger.class.getName(); 33 34 protected Logger(String name) { 35 super(name); 36 } 37 38 public static Logger getLogger(String name) { 39 return Log4jLoggerFactory.getLogger(name); 40 } 41 42 public static Logger getLogger(Class clazz) { 43 return getLogger(clazz.getName()); 44 } 45 46 /** 47 * Does the obvious. 48 * 49 * @return 50 */ 51 public static Logger getRootLogger() { 52 return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); 53 } 54 55 56 /** 57 * Delegates to {@link org.slf4j.Logger#isTraceEnabled} 58 * method of SLF4J. 59 */ 60 public boolean isTraceEnabled() { 61 return slf4jLogger.isTraceEnabled(); 62 } 63 64 /** 65 * Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J. 66 */ 67 public void trace(Object message) { 68 differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null); 69 } 70 71 /** 72 * Delegates to {@link org.slf4j.Logger#trace(String,Throwable)} 73 * method in SLF4J. 74 */ 75 public void trace(Object message, Throwable t) { 76 differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null); 77 } 78 79 }