1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.logging.log4j2;
17
18 import org.apache.ibatis.logging.Log;
19 import org.apache.logging.log4j.LogManager;
20 import org.apache.logging.log4j.Logger;
21 import org.apache.logging.log4j.spi.AbstractLogger;
22
23
24
25
26 public class Log4j2Impl implements Log {
27
28 private Log log;
29
30 public Log4j2Impl(String clazz) {
31 Logger logger = LogManager.getLogger(clazz);
32
33 if (logger instanceof AbstractLogger) {
34 log = new Log4j2AbstractLoggerImpl((AbstractLogger) logger);
35 } else {
36 log = new Log4j2LoggerImpl(logger);
37 }
38 }
39
40 @Override
41 public boolean isDebugEnabled() {
42 return log.isDebugEnabled();
43 }
44
45 @Override
46 public boolean isTraceEnabled() {
47 return log.isTraceEnabled();
48 }
49
50 @Override
51 public void error(String s, Throwable e) {
52 log.error(s, e);
53 }
54
55 @Override
56 public void error(String s) {
57 log.error(s);
58 }
59
60 @Override
61 public void debug(String s) {
62 log.debug(s);
63 }
64
65 @Override
66 public void trace(String s) {
67 log.trace(s);
68 }
69
70 @Override
71 public void warn(String s) {
72 log.warn(s);
73 }
74
75 }