1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.log4j.spi;
18
19 import org.apache.log4j.Level;
20 import org.apache.log4j.Logger;
21 import org.apache.log4j.ULogger;
22 import org.apache.log4j.helpers.MessageFormatter;
23
24
25
26
27
28 public final class Log4JULogger implements ULogger {
29
30
31
32
33 private final Logger logger;
34
35
36
37
38
39
40 public Log4JULogger(final Logger l) {
41 super();
42 if (l == null) {
43 throw new NullPointerException("l");
44 }
45 logger = l;
46 }
47
48
49
50
51 public boolean isDebugEnabled() {
52 return logger.isDebugEnabled();
53 }
54
55
56
57
58 public void debug(final Object msg) {
59 logger.debug(msg);
60 }
61
62
63
64
65 public void debug(final Object parameterizedMsg,
66 final Object param1) {
67 if (logger.isDebugEnabled()) {
68 logger.debug(MessageFormatter.format(
69 parameterizedMsg.toString(), param1));
70 }
71 }
72
73
74
75
76 public void debug(final String parameterizedMsg,
77 final Object param1,
78 final Object param2) {
79 if (logger.isDebugEnabled()) {
80 logger.debug(MessageFormatter.format(
81 parameterizedMsg, param1, param2));
82 }
83 }
84
85
86
87
88 public void debug(final Object msg,
89 final Throwable t) {
90 logger.debug(msg, t);
91 }
92
93
94
95
96
97 public boolean isInfoEnabled() {
98 return logger.isInfoEnabled();
99 }
100
101
102
103
104 public void info(final Object msg) {
105 logger.info(msg);
106 }
107
108
109
110
111
112 public void info(final Object parameterizedMsg,
113 final Object param1) {
114 if (logger.isInfoEnabled()) {
115 logger.info(MessageFormatter.format(
116 parameterizedMsg.toString(), param1));
117 }
118 }
119
120
121
122
123 public void info(final String parameterizedMsg,
124 final Object param1,
125 final Object param2) {
126 if (logger.isInfoEnabled()) {
127 logger.info(MessageFormatter.format(
128 parameterizedMsg,
129 param1,
130 param2));
131 }
132 }
133
134
135
136
137 public void info(final Object msg, final Throwable t) {
138 logger.info(msg, t);
139 }
140
141
142
143
144 public boolean isWarnEnabled() {
145 return logger.isEnabledFor(Level.WARN);
146 }
147
148
149
150
151 public void warn(final Object msg) {
152 logger.warn(msg);
153 }
154
155
156
157
158 public void warn(final Object parameterizedMsg,
159 final Object param1) {
160 if (logger.isEnabledFor(Level.WARN)) {
161 logger.warn(MessageFormatter.format(
162 parameterizedMsg.toString(), param1));
163 }
164 }
165
166
167
168
169 public void warn(final String parameterizedMsg,
170 final Object param1,
171 final Object param2) {
172 if (logger.isEnabledFor(Level.WARN)) {
173 logger.warn(MessageFormatter.format(
174 parameterizedMsg, param1, param2));
175 }
176 }
177
178
179
180
181 public void warn(final Object msg, final Throwable t) {
182 logger.warn(msg, t);
183 }
184
185
186
187
188 public boolean isErrorEnabled() {
189 return logger.isEnabledFor(Level.ERROR);
190 }
191
192
193
194
195 public void error(final Object msg) {
196 logger.error(msg);
197 }
198
199
200
201
202
203 public void error(final Object parameterizedMsg, final Object param1) {
204 if (logger.isEnabledFor(Level.ERROR)) {
205 logger.error(MessageFormatter.format(
206 parameterizedMsg.toString(), param1));
207 }
208 }
209
210
211
212
213 public void error(final String parameterizedMsg,
214 final Object param1,
215 final Object param2) {
216 if (logger.isEnabledFor(Level.ERROR)) {
217 logger.error(MessageFormatter.format(
218 parameterizedMsg, param1, param2));
219 }
220 }
221
222
223
224
225 public void error(final Object msg, final Throwable t) {
226 logger.error(msg, t);
227 }
228
229 }