1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.log4j;
18
19 import java.util.Hashtable;
20
21 import org.slf4j.helpers.Util;
22
23
24
25
26
27
28
29
30
31
32 class Log4jLoggerFactory {
33
34
35 private static Hashtable log4jLoggers = new Hashtable();
36
37 private static final String LOG4J_DELEGATION_LOOP_URL = "http://www.slf4j.org/codes.html#log4jDelegationLoop";
38
39
40 static {
41 try {
42 Class.forName("org.slf4j.impl.Log4jLoggerFactory");
43 String part1 = "Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. ";
44 String part2 = "See also " + LOG4J_DELEGATION_LOOP_URL
45 + " for more details.";
46
47 Util.report(part1);
48 Util.report(part2);
49 throw new IllegalStateException(part1 + part2);
50 } catch (ClassNotFoundException e) {
51
52 }
53 }
54
55 public static synchronized Logger getLogger(String name) {
56 if (log4jLoggers.containsKey(name)) {
57 return (org.apache.log4j.Logger) log4jLoggers.get(name);
58 } else {
59 Logger log4jLogger = new Logger(name);
60
61 log4jLoggers.put(name, log4jLogger);
62 return log4jLogger;
63 }
64 }
65
66 }