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