1 package org.apache.turbine.services.avaloncomponent;
2
3 import org.apache.avalon.framework.logger.Logger;
4 import org.apache.logging.log4j.LogManager;
5
6 /*
7 * Licensed to the Apache Software Foundation (ASF) under one or more
8 * contributor license agreements. See the NOTICE file distributed with
9 * this work for additional information regarding copyright ownership.
10 * The ASF licenses this file to You under the Apache License, Version 2.0
11 * (the "License"); you may not use this file except in compliance with
12 * the License. You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22
23 /**
24 * A Log4J2 wrapper class for Logger.
25 *
26 * Use org.apache.fulcrum.yaafi.framework.logger.Log4j2Logger instead.
27 *
28 * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
29 */
30 @Deprecated
31 public final class Log4j2Logger
32 implements Logger
33 {
34 // underlying implementation
35 private final org.apache.logging.log4j.Logger m_logger;
36
37 /**
38 * Create a logger that delegates to specified category.
39 *
40 * @param logImpl
41 * the category to delegate to
42 */
43 public Log4j2Logger(final org.apache.logging.log4j.Logger logImpl)
44 {
45 m_logger = logImpl;
46 }
47
48 /**
49 * Log a debug message.
50 *
51 * @param message
52 * the message
53 */
54 @Override
55 public void debug(final String message)
56 {
57 m_logger.debug(message);
58 }
59
60 /**
61 * Log a debug message.
62 *
63 * @param message
64 * the message
65 * @param throwable
66 * the throwable
67 */
68 @Override
69 public void debug(final String message, final Throwable throwable)
70 {
71 m_logger.debug(message, throwable);
72 }
73
74 /**
75 * Determine if messages of priority "debug" will be logged.
76 *
77 * @return true if "debug" messages will be logged
78 */
79 @Override
80 public boolean isDebugEnabled()
81 {
82 return m_logger.isDebugEnabled();
83 }
84
85 /**
86 * Log a info message.
87 *
88 * @param message
89 * the message
90 */
91 @Override
92 public void info(final String message)
93 {
94 m_logger.info(message);
95 }
96
97 /**
98 * Log a info message.
99 *
100 * @param message
101 * the message
102 * @param throwable
103 * the throwable
104 */
105 @Override
106 public void info(final String message, final Throwable throwable)
107 {
108 m_logger.info(message, throwable);
109 }
110
111 /**
112 * Determine if messages of priority "info" will be logged.
113 *
114 * @return true if "info" messages will be logged
115 */
116 @Override
117 public boolean isInfoEnabled()
118 {
119 return m_logger.isInfoEnabled();
120 }
121
122 /**
123 * Log a warn message.
124 *
125 * @param message
126 * the message
127 */
128 @Override
129 public void warn(final String message)
130 {
131 m_logger.warn(message);
132 }
133
134 /**
135 * Log a warn message.
136 *
137 * @param message
138 * the message
139 * @param throwable
140 * the throwable
141 */
142 @Override
143 public void warn(final String message, final Throwable throwable)
144 {
145 m_logger.warn(message, throwable);
146 }
147
148 /**
149 * Determine if messages of priority "warn" will be logged.
150 *
151 * @return true if "warn" messages will be logged
152 */
153 @Override
154 public boolean isWarnEnabled()
155 {
156 return m_logger.isWarnEnabled();
157 }
158
159 /**
160 * Log a error message.
161 *
162 * @param message
163 * the message
164 */
165 @Override
166 public void error(final String message)
167 {
168 m_logger.error(message);
169 }
170
171 /**
172 * Log a error message.
173 *
174 * @param message
175 * the message
176 * @param throwable
177 * the throwable
178 */
179 @Override
180 public void error(final String message, final Throwable throwable)
181 {
182 m_logger.error(message, throwable);
183 }
184
185 /**
186 * Determine if messages of priority "error" will be logged.
187 *
188 * @return true if "error" messages will be logged
189 */
190 @Override
191 public boolean isErrorEnabled()
192 {
193 return m_logger.isErrorEnabled();
194 }
195
196 /**
197 * Log a fatalError message.
198 *
199 * @param message
200 * the message
201 */
202 @Override
203 public void fatalError(final String message)
204 {
205 m_logger.fatal(message);
206 }
207
208 /**
209 * Log a fatalError message.
210 *
211 * @param message
212 * the message
213 * @param throwable
214 * the throwable
215 */
216 @Override
217 public void fatalError(final String message, final Throwable throwable)
218 {
219 m_logger.fatal(message, throwable);
220 }
221
222 /**
223 * Determine if messages of priority "fatalError" will be logged.
224 *
225 * @return true if "fatalError" messages will be logged
226 */
227 @Override
228 public boolean isFatalErrorEnabled()
229 {
230 return m_logger.isFatalEnabled();
231 }
232
233 /**
234 * Create a new child logger. The name of the child logger is
235 * [current-loggers-name].[passed-in-name] Throws
236 * <code>IllegalArgumentException</code> if name has an empty element name
237 *
238 * @param name
239 * the subname of this logger
240 * @return the new logger
241 */
242 @Override
243 public Logger getChildLogger(final String name)
244 {
245 return new Log4j2Logger(LogManager.getLogger(m_logger.getName() + "." + name));
246 }
247 }