annotate src/goodjava/logging/Log4jFactory.java @ 1448:6fc083e1d08c

start logger
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 23 Feb 2020 18:14:32 -0700
parents 27efb1fcbcb5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1402
27efb1fcbcb5 move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents: 1337
diff changeset
1 package goodjava.logging;
1337
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3
1448
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents: 1402
diff changeset
4 public final class Log4jFactory implements ILoggerFactory {
1337
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 private static final class Log4jLogger implements Logger {
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 final org.apache.log4j.Logger log4j;
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 Log4jLogger(org.apache.log4j.Logger log4j) {
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 this.log4j = log4j;
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 }
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 @Override public void error(String msg) {
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 log4j.error(msg);
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 }
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 @Override public void error(String msg,Throwable t) {
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 log4j.error(msg,t);
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 }
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 @Override public void warn(String msg) {
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 log4j.warn(msg);
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 }
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 @Override public void warn(String msg,Throwable t) {
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 log4j.warn(msg,t);
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 }
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 @Override public void info(String msg) {
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 log4j.info(msg);
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 }
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 @Override public void info(String msg,Throwable t) {
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 log4j.info(msg,t);
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 }
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35
1448
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents: 1402
diff changeset
36 @Override public boolean isInfoEnabled() {
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents: 1402
diff changeset
37 return log4j.isInfoEnabled();
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents: 1402
diff changeset
38 }
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents: 1402
diff changeset
39
1337
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 @Override public void debug(String msg) {
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 log4j.debug(msg);
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 }
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 @Override public void debug(String msg,Throwable t) {
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 log4j.debug(msg,t);
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 }
1448
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents: 1402
diff changeset
47
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents: 1402
diff changeset
48 @Override public boolean isDebugEnabled() {
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents: 1402
diff changeset
49 return log4j.isDebugEnabled();
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents: 1402
diff changeset
50 }
1337
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 }
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52
1448
6fc083e1d08c start logger
Franklin Schmidt <fschmidt@gmail.com>
parents: 1402
diff changeset
53 @Override public Logger getLogger(String name) {
1337
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 return new Log4jLogger(org.apache.log4j.Logger.getLogger(name));
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 }
8b61c8c4e07a remove slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 }