1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.Core
.Logging
20 /// Supporting Logger levels.
22 public enum LoggerLevel
25 /// Logging will be off
29 /// Fatal logging level
33 /// Error logging level
37 /// Warn logging level
41 /// Info logging level
45 /// Debug logging level
54 /// This is a facade for the different logging subsystems.
55 /// It offers a simplified interface that follows IOC patterns
56 /// and a simplified priority/level/severity abstraction.
58 public interface ILogger
63 /// Logs a debug message.
65 /// <param name="message">The message to log</param>
66 void Debug(String message
);
69 /// Logs a debug message.
71 /// <param name="exception">The exception to log</param>
72 /// <param name="message">The message to log</param>
73 void Debug(String message
, Exception exception
);
76 /// Logs a debug message.
78 /// <param name="format">Format string for the message to log</param>
79 /// <param name="args">Format arguments for the message to log</param>
80 void Debug(String format
, params Object
[] args
);
83 /// Logs a debug message.
85 /// <param name="format">Format string for the message to log</param>
86 /// <param name="args">Format arguments for the message to log</param>
87 void DebugFormat(String format
, params Object
[] args
);
90 /// Logs a debug message.
92 /// <param name="exception">The exception to log</param>
93 /// <param name="format">Format string for the message to log</param>
94 /// <param name="args">Format arguments for the message to log</param>
95 void DebugFormat(Exception exception
, String format
, params Object
[] args
);
98 /// Logs a debug message.
100 /// <param name="formatProvider">The format provider to use</param>
101 /// <param name="format">Format string for the message to log</param>
102 /// <param name="args">Format arguments for the message to log</param>
103 void DebugFormat(IFormatProvider formatProvider
, String format
, params Object
[] args
);
106 /// Logs a debug message.
108 /// <param name="exception">The exception to log</param>
109 /// <param name="formatProvider">The format provider to use</param>
110 /// <param name="format">Format string for the message to log</param>
111 /// <param name="args">Format arguments for the message to log</param>
112 void DebugFormat(Exception exception
, IFormatProvider formatProvider
, String format
, params Object
[] args
);
116 /// Determines if messages of priority "debug" will be logged.
118 /// <value>True if "debug" messages will be logged.</value>
119 bool IsDebugEnabled { get; }
126 /// Logs an info message.
128 /// <param name="message">The message to log</param>
129 void Info(String message
);
132 /// Logs an info message.
134 /// <param name="exception">The exception to log</param>
135 /// <param name="message">The message to log</param>
136 void Info(String message
, Exception exception
);
139 /// Logs an info message.
141 /// <param name="format">Format string for the message to log</param>
142 /// <param name="args">Format arguments for the message to log</param>
143 void Info(String format
, params Object
[] args
);
146 /// Logs an info message.
148 /// <param name="format">Format string for the message to log</param>
149 /// <param name="args">Format arguments for the message to log</param>
150 void InfoFormat(String format
, params Object
[] args
);
153 /// Logs an info message.
155 /// <param name="exception">The exception to log</param>
156 /// <param name="format">Format string for the message to log</param>
157 /// <param name="args">Format arguments for the message to log</param>
158 void InfoFormat(Exception exception
, String format
, params Object
[] args
);
161 /// Logs an info message.
163 /// <param name="formatProvider">The format provider to use</param>
164 /// <param name="format">Format string for the message to log</param>
165 /// <param name="args">Format arguments for the message to log</param>
166 void InfoFormat(IFormatProvider formatProvider
, String format
, params Object
[] args
);
169 /// Logs an info message.
171 /// <param name="exception">The exception to log</param>
172 /// <param name="formatProvider">The format provider to use</param>
173 /// <param name="format">Format string for the message to log</param>
174 /// <param name="args">Format arguments for the message to log</param>
175 void InfoFormat(Exception exception
, IFormatProvider formatProvider
, String format
, params Object
[] args
);
179 /// Determines if messages of priority "info" will be logged.
181 /// <value>True if "info" messages will be logged.</value>
182 bool IsInfoEnabled { get; }
189 /// Logs a warn message.
191 /// <param name="message">The message to log</param>
192 void Warn(String message
);
195 /// Logs a warn message.
197 /// <param name="exception">The exception to log</param>
198 /// <param name="message">The message to log</param>
199 void Warn(String message
, Exception exception
);
202 /// Logs a warn message.
204 /// <param name="format">Format string for the message to log</param>
205 /// <param name="args">Format arguments for the message to log</param>
206 void Warn(String format
, params Object
[] args
);
209 /// Logs a warn message.
211 /// <param name="format">Format string for the message to log</param>
212 /// <param name="args">Format arguments for the message to log</param>
213 void WarnFormat(String format
, params Object
[] args
);
216 /// Logs a warn message.
218 /// <param name="exception">The exception to log</param>
219 /// <param name="format">Format string for the message to log</param>
220 /// <param name="args">Format arguments for the message to log</param>
221 void WarnFormat(Exception exception
, String format
, params Object
[] args
);
224 /// Logs a warn message.
226 /// <param name="formatProvider">The format provider to use</param>
227 /// <param name="format">Format string for the message to log</param>
228 /// <param name="args">Format arguments for the message to log</param>
229 void WarnFormat(IFormatProvider formatProvider
, String format
, params Object
[] args
);
232 /// Logs a warn message.
234 /// <param name="exception">The exception to log</param>
235 /// <param name="formatProvider">The format provider to use</param>
236 /// <param name="format">Format string for the message to log</param>
237 /// <param name="args">Format arguments for the message to log</param>
238 void WarnFormat(Exception exception
, IFormatProvider formatProvider
, String format
, params Object
[] args
);
242 /// Determines if messages of priority "warn" will be logged.
244 /// <value>True if "warn" messages will be logged.</value>
245 bool IsWarnEnabled { get; }
252 /// Logs an error message.
254 /// <param name="message">The message to log</param>
255 void Error(String message
);
258 /// Logs an error message.
260 /// <param name="exception">The exception to log</param>
261 /// <param name="message">The message to log</param>
262 void Error(String message
, Exception exception
);
265 /// Logs an error message.
267 /// <param name="format">Format string for the message to log</param>
268 /// <param name="args">Format arguments for the message to log</param>
269 void Error(String format
, params Object
[] args
);
272 /// Logs an error message.
274 /// <param name="format">Format string for the message to log</param>
275 /// <param name="args">Format arguments for the message to log</param>
276 void ErrorFormat(String format
, params Object
[] args
);
279 /// Logs an error message.
281 /// <param name="exception">The exception to log</param>
282 /// <param name="format">Format string for the message to log</param>
283 /// <param name="args">Format arguments for the message to log</param>
284 void ErrorFormat(Exception exception
, String format
, params Object
[] args
);
287 /// Logs an error message.
289 /// <param name="formatProvider">The format provider to use</param>
290 /// <param name="format">Format string for the message to log</param>
291 /// <param name="args">Format arguments for the message to log</param>
292 void ErrorFormat(IFormatProvider formatProvider
, String format
, params Object
[] args
);
295 /// Logs an error message.
297 /// <param name="exception">The exception to log</param>
298 /// <param name="formatProvider">The format provider to use</param>
299 /// <param name="format">Format string for the message to log</param>
300 /// <param name="args">Format arguments for the message to log</param>
301 void ErrorFormat(Exception exception
, IFormatProvider formatProvider
, String format
, params Object
[] args
);
305 /// Determines if messages of priority "error" will be logged.
307 /// <value>True if "error" messages will be logged.</value>
308 bool IsErrorEnabled { get; }
315 /// Logs a fatal message.
317 /// <param name="message">The message to log</param>
318 void Fatal(String message
);
321 /// Logs a fatal message.
323 /// <param name="exception">The exception to log</param>
324 /// <param name="message">The message to log</param>
325 void Fatal(String message
, Exception exception
);
328 /// Logs a fatal message.
330 /// <param name="format">Format string for the message to log</param>
331 /// <param name="args">Format arguments for the message to log</param>
332 void Fatal(String format
, params Object
[] args
);
335 /// Logs a fatal message.
337 /// <param name="format">Format string for the message to log</param>
338 /// <param name="args">Format arguments for the message to log</param>
339 void FatalFormat(String format
, params Object
[] args
);
342 /// Logs a fatal message.
344 /// <param name="exception">The exception to log</param>
345 /// <param name="format">Format string for the message to log</param>
346 /// <param name="args">Format arguments for the message to log</param>
347 void FatalFormat(Exception exception
, String format
, params Object
[] args
);
350 /// Logs a fatal message.
352 /// <param name="formatProvider">The format provider to use</param>
353 /// <param name="format">Format string for the message to log</param>
354 /// <param name="args">Format arguments for the message to log</param>
355 void FatalFormat(IFormatProvider formatProvider
, String format
, params Object
[] args
);
358 /// Logs a fatal message.
360 /// <param name="exception">The exception to log</param>
361 /// <param name="formatProvider">The format provider to use</param>
362 /// <param name="format">Format string for the message to log</param>
363 /// <param name="args">Format arguments for the message to log</param>
364 void FatalFormat(Exception exception
, IFormatProvider formatProvider
, String format
, params Object
[] args
);
368 /// Determines if messages of priority "fatal" will be logged.
370 /// <value>True if "fatal" messages will be logged.</value>
371 bool IsFatalEnabled { get; }
375 #region FatalError (obsolete)
378 /// Logs a fatal error message.
380 /// <param name="message">The Message</param>
381 [Obsolete("Use Fatal instead")]
382 void FatalError(String message
);
385 /// Logs a fatal error message.
387 /// <param name="message">The Message</param>
388 /// <param name="exception">The Exception</param>
389 [Obsolete("Use Fatal instead")]
390 void FatalError(String message
, Exception exception
);
393 /// Logs a fatal error message.
395 /// <param name="format">Message format</param>
396 /// <param name="args">Array of objects to write using format</param>
397 [Obsolete("Use Fatal or FatalFormat instead")]
398 void FatalError(String format
, params Object
[] args
);
401 /// Determines if messages of priority "fatalError" will be logged.
403 /// <value>True if "fatalError" messages will be logged.</value>
404 [Obsolete("Use IsFatalEnabled instead")]
405 bool IsFatalErrorEnabled { get; }
410 /// Create a new child logger.
411 /// The name of the child logger is [current-loggers-name].[passed-in-name]
413 /// <param name="name">The Subname of this logger.</param>
414 /// <returns>The New ILogger instance.</returns>
415 /// <exception cref="System.ArgumentException">If the name has an empty element name.</exception>
416 ILogger
CreateChildLogger(String name
);