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