1
2
3
4
5
6
7
8
9
10
11 package psiprobe.tools.logging.log4j;
12
13 import java.io.File;
14 import java.nio.file.Path;
15
16 import psiprobe.tools.logging.AbstractLogDestination;
17
18
19
20
21 public class Log4JAppenderAccessor extends AbstractLogDestination {
22
23
24 private Log4JLoggerAccessor loggerAccessor;
25
26
27
28
29
30
31 public Log4JLoggerAccessor getLoggerAccessor() {
32 return loggerAccessor;
33 }
34
35
36
37
38
39
40 public void setLoggerAccessor(Log4JLoggerAccessor loggerAccessor) {
41 this.loggerAccessor = loggerAccessor;
42 }
43
44 @Override
45 public boolean isContext() {
46 return getLoggerAccessor().isContext();
47 }
48
49 @Override
50 public boolean isRoot() {
51 return getLoggerAccessor().isRoot();
52 }
53
54 @Override
55 public String getName() {
56 return getLoggerAccessor().getName();
57 }
58
59 @Override
60 public String getLogType() {
61 return "log4j";
62 }
63
64 @Override
65 public String getIndex() {
66 return (String) getProperty(getTarget(), "name", null);
67 }
68
69 @Override
70 public String getConversionPattern() {
71 Object layout = getProperty(getTarget(), "layout", null);
72 if (layout != null && "org.apache.log4j.PatternLayout".equals(layout.getClass().getName())) {
73 return (String) getProperty(layout, "conversionPattern", null);
74 }
75 return null;
76 }
77
78 @Override
79 public File getFile() {
80 String fileName = (String) getProperty(getTarget(), "file", null);
81 return fileName != null ? Path.of(fileName).toFile() : getStdoutFile();
82 }
83
84 @Override
85 public String getLevel() {
86 return getLoggerAccessor().getLevel();
87 }
88
89 @Override
90 public String[] getValidLevels() {
91 return new String[] {"OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "ALL"};
92 }
93
94 }