1
2
3
4
5
6
7
8
9
10
11 package psiprobe.tools.logging.log4j2;
12
13 import java.util.Map;
14
15 import psiprobe.tools.logging.DefaultAccessor;
16
17
18
19
20 public class Log4J2LoggerContextAccessor extends DefaultAccessor {
21
22
23
24
25
26
27 public Map<String, Object> getLoggers() {
28 Map<String, Object> loggers = null;
29 Object configuration = null;
30 try {
31 configuration = invokeMethod(getTarget(), "getConfiguration", null, null);
32 } catch (Exception e) {
33 logger.error("exception invoking getConfiguration", e);
34 throw e;
35 }
36 if (configuration != null) {
37 try {
38 loggers = (Map<String, Object>) invokeMethod(configuration, "getLoggers", null, null);
39 } catch (Exception e) {
40 logger.error("exception invoking getLoggers", e);
41 throw e;
42 }
43 }
44 return loggers;
45 }
46
47
48
49
50 public void updateLoggers() {
51 try {
52 invokeMethod(getTarget(), "updateLoggers", null, null);
53 } catch (Exception e) {
54 logger.error("exception invoking updateLoggers", e);
55 throw e;
56 }
57 }
58 }