1
2
3
4
5
6
7
8
9
10
11 package psiprobe.tools.logging.slf4jlogback13;
12
13 import ch.qos.logback.core.OutputStreamAppender;
14 import ch.qos.logback.core.encoder.Encoder;
15 import ch.qos.logback.core.encoder.LayoutWrappingEncoder;
16
17 import java.io.File;
18
19 import psiprobe.tools.logging.AbstractLogDestination;
20
21
22
23
24 public class TomcatSlf4jLogback13AppenderAccessor extends AbstractLogDestination {
25
26
27 private TomcatSlf4jLogback13LoggerAccessor loggerAccessor;
28
29
30
31
32
33
34 public TomcatSlf4jLogback13LoggerAccessor getLoggerAccessor() {
35 return loggerAccessor;
36 }
37
38
39
40
41
42
43 public void setLoggerAccessor(TomcatSlf4jLogback13LoggerAccessor loggerAccessor) {
44 this.loggerAccessor = loggerAccessor;
45 }
46
47 @Override
48 public boolean isContext() {
49 return getLoggerAccessor().isContext();
50 }
51
52 @Override
53 public boolean isRoot() {
54 return getLoggerAccessor().isRoot();
55 }
56
57 @Override
58 public String getName() {
59 return getLoggerAccessor().getName();
60 }
61
62
63
64
65
66
67
68 @Override
69 public String getLogType() {
70 return "tomcatSlf4jLogback13";
71 }
72
73
74
75
76
77
78 @Override
79 public String getIndex() {
80 return (String) getProperty(getTarget(), "name", null);
81 }
82
83
84
85
86
87
88
89
90
91
92
93 @Override
94 public File getFile() {
95 String fileName = (String) getProperty(getTarget(), "file", null);
96 return fileName != null ? new File(fileName) : getStdoutFile();
97 }
98
99 @Override
100 public String getEncoding() {
101 if (getTarget() instanceof OutputStreamAppender) {
102 OutputStreamAppender<?> appender = (OutputStreamAppender<?>) getTarget();
103 Encoder<?> encoder = appender.getEncoder();
104 if (encoder instanceof LayoutWrappingEncoder) {
105 LayoutWrappingEncoder<?> base = (LayoutWrappingEncoder<?>) encoder;
106 if (base.getCharset() != null) {
107 return base.getCharset().name();
108 }
109 }
110 }
111 return null;
112 }
113
114
115
116
117
118
119 @Override
120 public String getLevel() {
121 return getLoggerAccessor().getLevel();
122 }
123
124
125
126
127
128
129
130
131
132 @Override
133 public String[] getValidLevels() {
134 return new String[] {"OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "ALL"};
135 }
136
137 }