1 //-----------------------------------------------------------------------
2 // <copyright file="Logger.cs" company="Andrew Arnott">
3 // Copyright (c) Andrew Arnott. All rights reserved.
5 //-----------------------------------------------------------------------
7 namespace DotNetOpenAuth
{
9 using System
.Globalization
;
10 using DotNetOpenAuth
.Loggers
;
14 /// A general logger for the entire DotNetOpenAuth library.
17 /// Because this logger is intended for use with non-localized strings, the
18 /// overloads that take <see cref="CultureInfo"/> have been removed, and
19 /// <see cref="CultureInfo.InvariantCulture"/> is used implicitly.
21 internal static class Logger
{
23 /// The <see cref="ILog"/> instance that is to be used
24 /// by this static Logger for the duration of the appdomain.
26 private static ILog facade
= Create("DotNetOpenAuth");
29 //// Although this static class doesn't literally implement the ILog interface,
30 //// we implement (mostly) all the same methods in a static way.
33 /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Debug"/> level.
36 /// <c>true</c> if this logger is enabled for <see cref="Level.Debug"/> events, <c>false</c> otherwise.
40 /// This function is intended to lessen the computational cost of
41 /// disabled log debug statements.
43 /// <para> For some ILog interface <c>log</c>, when you write:</para>
45 /// log.Debug("This is entry number: " + i );
48 /// You incur the cost constructing the message, string construction and concatenation in
49 /// this case, regardless of whether the message is logged or not.
52 /// If you are worried about speed (who isn't), then you should write:
55 /// if (log.IsDebugEnabled)
57 /// log.Debug("This is entry number: " + i );
61 /// This way you will not incur the cost of parameter
62 /// construction if debugging is disabled for <c>log</c>. On
63 /// the other hand, if the <c>log</c> is debug enabled, you
64 /// will incur the cost of evaluating whether the logger is debug
65 /// enabled twice. Once in <see cref="IsDebugEnabled"/> and once in
66 /// the <see cref="Debug(object)"/>. This is an insignificant overhead
67 /// since evaluating a logger takes about 1% of the time it
68 /// takes to actually log. This is the preferred style of logging.
70 /// <para>Alternatively if your logger is available statically then the is debug
71 /// enabled state can be stored in a static variable like this:
74 /// private static readonly bool isDebugEnabled = log.IsDebugEnabled;
77 /// Then when you come to log you can write:
80 /// if (isDebugEnabled)
82 /// log.Debug("This is entry number: " + i );
86 /// This way the debug enabled state is only queried once
87 /// when the class is loaded. Using a <c>private static readonly</c>
88 /// variable is the most efficient because it is a run time constant
89 /// and can be heavily optimized by the JIT compiler.
92 /// Of course if you use a static readonly variable to
93 /// hold the enabled state of the logger then you cannot
94 /// change the enabled state at runtime to vary the logging
95 /// that is produced. You have to decide if you need absolute
96 /// speed or runtime flexibility.
99 /// <seealso cref="Debug(object)"/>
100 /// <seealso cref="DebugFormat(string, object[])"/>
101 public static bool IsDebugEnabled
{
102 get { return facade.IsDebugEnabled; }
106 /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Info"/> level.
109 /// <c>true</c> if this logger is enabled for <see cref="Level.Info"/> events, <c>false</c> otherwise.
112 /// For more information see <see cref="ILog.IsDebugEnabled"/>.
114 /// <seealso cref="Info(object)"/>
115 /// <seealso cref="InfoFormat(string, object[])"/>
116 /// <seealso cref="ILog.IsDebugEnabled"/>
117 public static bool IsInfoEnabled
{
118 get { return facade.IsInfoEnabled; }
122 /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Warn"/> level.
125 /// <c>true</c> if this logger is enabled for <see cref="Level.Warn"/> events, <c>false</c> otherwise.
128 /// For more information see <see cref="ILog.IsDebugEnabled"/>.
130 /// <seealso cref="Warn(object)"/>
131 /// <seealso cref="WarnFormat(string, object[])"/>
132 /// <seealso cref="ILog.IsDebugEnabled"/>
133 public static bool IsWarnEnabled
{
134 get { return facade.IsWarnEnabled; }
138 /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Error"/> level.
141 /// <c>true</c> if this logger is enabled for <see cref="Level.Error"/> events, <c>false</c> otherwise.
144 /// For more information see <see cref="ILog.IsDebugEnabled"/>.
146 /// <seealso cref="Error(object)"/>
147 /// <seealso cref="ErrorFormat(string, object[])"/>
148 /// <seealso cref="ILog.IsDebugEnabled"/>
149 public static bool IsErrorEnabled
{
150 get { return facade.IsErrorEnabled; }
154 /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Fatal"/> level.
157 /// <c>true</c> if this logger is enabled for <see cref="Level.Fatal"/> events, <c>false</c> otherwise.
160 /// For more information see <see cref="ILog.IsDebugEnabled"/>.
162 /// <seealso cref="Fatal(object)"/>
163 /// <seealso cref="FatalFormat(string, object[])"/>
164 /// <seealso cref="ILog.IsDebugEnabled"/>
165 public static bool IsFatalEnabled
{
166 get { return facade.IsFatalEnabled; }
169 /// <overloads>Log a message object with the <see cref="Level.Debug"/> level.</overloads>
171 /// Log a message object with the <see cref="Level.Debug"/> level.
173 /// <param name="message">The message object to log.</param>
176 /// This method first checks if this logger is <c>DEBUG</c>
177 /// enabled by comparing the level of this logger with the
178 /// <see cref="Level.Debug"/> level. If this logger is
179 /// <c>DEBUG</c> enabled, then it converts the message object
180 /// (passed as parameter) to a string by invoking the appropriate
181 /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
182 /// proceeds to call all the registered appenders in this logger
183 /// and also higher in the hierarchy depending on the value of
184 /// the additivity flag.
186 /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
187 /// to this method will print the name of the <see cref="Exception"/>
188 /// but no stack trace. To print a stack trace use the
189 /// <see cref="Debug(object,Exception)"/> form instead.
192 /// <seealso cref="Debug(object,Exception)"/>
193 /// <seealso cref="IsDebugEnabled"/>
194 public static void Debug(object message
) {
195 facade
.Debug(message
);
199 /// Log a message object with the <see cref="Level.Debug"/> level including
200 /// the stack trace of the <see cref="Exception"/> passed
203 /// <param name="message">The message object to log.</param>
204 /// <param name="exception">The exception to log, including its stack trace.</param>
207 /// See the <see cref="Debug(object)"/> form for more detailed information.
210 /// <seealso cref="Debug(object)"/>
211 /// <seealso cref="IsDebugEnabled"/>
212 public static void Debug(object message
, Exception exception
) {
213 facade
.Debug(message
, exception
);
216 /// <overloads>Log a formatted string with the <see cref="Level.Debug"/> level.</overloads>
218 /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
220 /// <param name="format">A String containing zero or more format items</param>
221 /// <param name="args">An Object array containing zero or more objects to format</param>
224 /// The message is formatted using the <c>String.Format</c> method. See
225 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
226 /// of the formatting.
229 /// This method does not take an <see cref="Exception"/> object to include in the
230 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
234 /// <seealso cref="Debug(object)"/>
235 /// <seealso cref="IsDebugEnabled"/>
236 public static void DebugFormat(string format
, params object[] args
) {
237 facade
.DebugFormat(CultureInfo
.InvariantCulture
, format
, args
);
241 /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
243 /// <param name="format">A String containing zero or more format items</param>
244 /// <param name="arg0">An Object to format</param>
247 /// The message is formatted using the <c>String.Format</c> method. See
248 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
249 /// of the formatting.
252 /// This method does not take an <see cref="Exception"/> object to include in the
253 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
257 /// <seealso cref="Debug(object)"/>
258 /// <seealso cref="IsDebugEnabled"/>
259 public static void DebugFormat(string format
, object arg0
) {
260 facade
.DebugFormat(format
, arg0
);
264 /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
266 /// <param name="format">A String containing zero or more format items</param>
267 /// <param name="arg0">An Object to format</param>
268 /// <param name="arg1">An Object to format</param>
271 /// The message is formatted using the <c>String.Format</c> method. See
272 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
273 /// of the formatting.
276 /// This method does not take an <see cref="Exception"/> object to include in the
277 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
281 /// <seealso cref="Debug(object)"/>
282 /// <seealso cref="IsDebugEnabled"/>
283 public static void DebugFormat(string format
, object arg0
, object arg1
) {
284 facade
.DebugFormat(format
, arg0
, arg1
);
288 /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
290 /// <param name="format">A String containing zero or more format items</param>
291 /// <param name="arg0">An Object to format</param>
292 /// <param name="arg1">An Object to format</param>
293 /// <param name="arg2">An Object to format</param>
296 /// The message is formatted using the <c>String.Format</c> method. See
297 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
298 /// of the formatting.
301 /// This method does not take an <see cref="Exception"/> object to include in the
302 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
306 /// <seealso cref="Debug(object)"/>
307 /// <seealso cref="IsDebugEnabled"/>
308 public static void DebugFormat(string format
, object arg0
, object arg1
, object arg2
) {
309 facade
.DebugFormat(format
, arg0
, arg1
, arg2
);
313 public static void DebugFormat(IFormatProvider provider, string format, params object[] args) {
314 facade.DebugFormat(provider, format, args);
318 /// <overloads>Log a message object with the <see cref="Level.Info"/> level.</overloads>
320 /// Logs a message object with the <see cref="Level.Info"/> level.
324 /// This method first checks if this logger is <c>INFO</c>
325 /// enabled by comparing the level of this logger with the
326 /// <see cref="Level.Info"/> level. If this logger is
327 /// <c>INFO</c> enabled, then it converts the message object
328 /// (passed as parameter) to a string by invoking the appropriate
329 /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
330 /// proceeds to call all the registered appenders in this logger
331 /// and also higher in the hierarchy depending on the value of the
334 /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
335 /// to this method will print the name of the <see cref="Exception"/>
336 /// but no stack trace. To print a stack trace use the
337 /// <see cref="Info(object,Exception)"/> form instead.
340 /// <param name="message">The message object to log.</param>
341 /// <seealso cref="Info(object,Exception)"/>
342 /// <seealso cref="IsInfoEnabled"/>
343 public static void Info(object message
) {
344 facade
.Info(message
);
348 /// Logs a message object with the <c>INFO</c> level including
349 /// the stack trace of the <see cref="Exception"/> passed
352 /// <param name="message">The message object to log.</param>
353 /// <param name="exception">The exception to log, including its stack trace.</param>
356 /// See the <see cref="Info(object)"/> form for more detailed information.
359 /// <seealso cref="Info(object)"/>
360 /// <seealso cref="IsInfoEnabled"/>
361 public static void Info(object message
, Exception exception
) {
362 facade
.Info(message
, exception
);
365 /// <overloads>Log a formatted message string with the <see cref="Level.Info"/> level.</overloads>
367 /// Logs a formatted message string with the <see cref="Level.Info"/> level.
369 /// <param name="format">A String containing zero or more format items</param>
370 /// <param name="args">An Object array containing zero or more objects to format</param>
373 /// The message is formatted using the <c>String.Format</c> method. See
374 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
375 /// of the formatting.
378 /// This method does not take an <see cref="Exception"/> object to include in the
379 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object)"/>
383 /// <seealso cref="Info(object,Exception)"/>
384 /// <seealso cref="IsInfoEnabled"/>
385 public static void InfoFormat(string format
, params object[] args
) {
386 facade
.InfoFormat(CultureInfo
.InvariantCulture
, format
, args
);
390 /// Logs a formatted message string with the <see cref="Level.Info"/> level.
392 /// <param name="format">A String containing zero or more format items</param>
393 /// <param name="arg0">An Object to format</param>
396 /// The message is formatted using the <c>String.Format</c> method. See
397 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
398 /// of the formatting.
401 /// This method does not take an <see cref="Exception"/> object to include in the
402 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/>
406 /// <seealso cref="Info(object)"/>
407 /// <seealso cref="IsInfoEnabled"/>
408 public static void InfoFormat(string format
, object arg0
) {
409 facade
.InfoFormat(format
, arg0
);
413 /// Logs a formatted message string with the <see cref="Level.Info"/> level.
415 /// <param name="format">A String containing zero or more format items</param>
416 /// <param name="arg0">An Object to format</param>
417 /// <param name="arg1">An Object to format</param>
420 /// The message is formatted using the <c>String.Format</c> method. See
421 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
422 /// of the formatting.
425 /// This method does not take an <see cref="Exception"/> object to include in the
426 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/>
430 /// <seealso cref="Info(object)"/>
431 /// <seealso cref="IsInfoEnabled"/>
432 public static void InfoFormat(string format
, object arg0
, object arg1
) {
433 facade
.InfoFormat(format
, arg0
, arg1
);
437 /// Logs a formatted message string with the <see cref="Level.Info"/> level.
439 /// <param name="format">A String containing zero or more format items</param>
440 /// <param name="arg0">An Object to format</param>
441 /// <param name="arg1">An Object to format</param>
442 /// <param name="arg2">An Object to format</param>
445 /// The message is formatted using the <c>String.Format</c> method. See
446 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
447 /// of the formatting.
450 /// This method does not take an <see cref="Exception"/> object to include in the
451 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/>
455 /// <seealso cref="Info(object)"/>
456 /// <seealso cref="IsInfoEnabled"/>
457 public static void InfoFormat(string format
, object arg0
, object arg1
, object arg2
) {
458 facade
.InfoFormat(format
, arg0
, arg1
, arg2
);
462 public static void InfoFormat(IFormatProvider provider, string format, params object[] args) {
463 facade.InfoFormat(provider, format, args);
467 /// <overloads>Log a message object with the <see cref="Level.Warn"/> level.</overloads>
469 /// Log a message object with the <see cref="Level.Warn"/> level.
473 /// This method first checks if this logger is <c>WARN</c>
474 /// enabled by comparing the level of this logger with the
475 /// <see cref="Level.Warn"/> level. If this logger is
476 /// <c>WARN</c> enabled, then it converts the message object
477 /// (passed as parameter) to a string by invoking the appropriate
478 /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
479 /// proceeds to call all the registered appenders in this logger
480 /// and also higher in the hierarchy depending on the value of the
483 /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
484 /// to this method will print the name of the <see cref="Exception"/>
485 /// but no stack trace. To print a stack trace use the
486 /// <see cref="Warn(object,Exception)"/> form instead.
489 /// <param name="message">The message object to log.</param>
490 /// <seealso cref="Warn(object,Exception)"/>
491 /// <seealso cref="IsWarnEnabled"/>
492 public static void Warn(object message
) {
493 facade
.Warn(message
);
497 /// Log a message object with the <see cref="Level.Warn"/> level including
498 /// the stack trace of the <see cref="Exception"/> passed
501 /// <param name="message">The message object to log.</param>
502 /// <param name="exception">The exception to log, including its stack trace.</param>
505 /// See the <see cref="Warn(object)"/> form for more detailed information.
508 /// <seealso cref="Warn(object)"/>
509 /// <seealso cref="IsWarnEnabled"/>
510 public static void Warn(object message
, Exception exception
) {
511 facade
.Warn(message
, exception
);
514 /// <overloads>Log a formatted message string with the <see cref="Level.Warn"/> level.</overloads>
516 /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
518 /// <param name="format">A String containing zero or more format items</param>
519 /// <param name="args">An Object array containing zero or more objects to format</param>
522 /// The message is formatted using the <c>String.Format</c> method. See
523 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
524 /// of the formatting.
527 /// This method does not take an <see cref="Exception"/> object to include in the
528 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object)"/>
532 /// <seealso cref="Warn(object,Exception)"/>
533 /// <seealso cref="IsWarnEnabled"/>
534 public static void WarnFormat(string format
, params object[] args
) {
535 facade
.WarnFormat(CultureInfo
.InvariantCulture
, format
, args
);
539 /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
541 /// <param name="format">A String containing zero or more format items</param>
542 /// <param name="arg0">An Object to format</param>
545 /// The message is formatted using the <c>String.Format</c> method. See
546 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
547 /// of the formatting.
550 /// This method does not take an <see cref="Exception"/> object to include in the
551 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/>
555 /// <seealso cref="Warn(object)"/>
556 /// <seealso cref="IsWarnEnabled"/>
557 public static void WarnFormat(string format
, object arg0
) {
558 facade
.WarnFormat(format
, arg0
);
562 /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
564 /// <param name="format">A String containing zero or more format items</param>
565 /// <param name="arg0">An Object to format</param>
566 /// <param name="arg1">An Object to format</param>
569 /// The message is formatted using the <c>String.Format</c> method. See
570 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
571 /// of the formatting.
574 /// This method does not take an <see cref="Exception"/> object to include in the
575 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/>
579 /// <seealso cref="Warn(object)"/>
580 /// <seealso cref="IsWarnEnabled"/>
581 public static void WarnFormat(string format
, object arg0
, object arg1
) {
582 facade
.WarnFormat(format
, arg0
, arg1
);
586 /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
588 /// <param name="format">A String containing zero or more format items</param>
589 /// <param name="arg0">An Object to format</param>
590 /// <param name="arg1">An Object to format</param>
591 /// <param name="arg2">An Object to format</param>
594 /// The message is formatted using the <c>String.Format</c> method. See
595 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
596 /// of the formatting.
599 /// This method does not take an <see cref="Exception"/> object to include in the
600 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/>
604 /// <seealso cref="Warn(object)"/>
605 /// <seealso cref="IsWarnEnabled"/>
606 public static void WarnFormat(string format
, object arg0
, object arg1
, object arg2
) {
607 facade
.WarnFormat(format
, arg0
, arg1
, arg2
);
611 public static void WarnFormat(IFormatProvider provider, string format, params object[] args) {
612 facade.WarnFormat(provider, format, args);
616 /// <overloads>Log a message object with the <see cref="Level.Error"/> level.</overloads>
618 /// Logs a message object with the <see cref="Level.Error"/> level.
620 /// <param name="message">The message object to log.</param>
623 /// This method first checks if this logger is <c>ERROR</c>
624 /// enabled by comparing the level of this logger with the
625 /// <see cref="Level.Error"/> level. If this logger is
626 /// <c>ERROR</c> enabled, then it converts the message object
627 /// (passed as parameter) to a string by invoking the appropriate
628 /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
629 /// proceeds to call all the registered appenders in this logger
630 /// and also higher in the hierarchy depending on the value of the
633 /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
634 /// to this method will print the name of the <see cref="Exception"/>
635 /// but no stack trace. To print a stack trace use the
636 /// <see cref="Error(object,Exception)"/> form instead.
639 /// <seealso cref="Error(object,Exception)"/>
640 /// <seealso cref="IsErrorEnabled"/>
641 public static void Error(object message
) {
642 facade
.Error(message
);
646 /// Log a message object with the <see cref="Level.Error"/> level including
647 /// the stack trace of the <see cref="Exception"/> passed
650 /// <param name="message">The message object to log.</param>
651 /// <param name="exception">The exception to log, including its stack trace.</param>
654 /// See the <see cref="Error(object)"/> form for more detailed information.
657 /// <seealso cref="Error(object)"/>
658 /// <seealso cref="IsErrorEnabled"/>
659 public static void Error(object message
, Exception exception
) {
660 facade
.Error(message
, exception
);
663 /// <overloads>Log a formatted message string with the <see cref="Level.Error"/> level.</overloads>
665 /// Logs a formatted message string with the <see cref="Level.Error"/> level.
667 /// <param name="format">A String containing zero or more format items</param>
668 /// <param name="args">An Object array containing zero or more objects to format</param>
671 /// The message is formatted using the <c>String.Format</c> method. See
672 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
673 /// of the formatting.
676 /// This method does not take an <see cref="Exception"/> object to include in the
677 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object)"/>
681 /// <seealso cref="Error(object,Exception)"/>
682 /// <seealso cref="IsErrorEnabled"/>
683 public static void ErrorFormat(string format
, params object[] args
) {
684 facade
.ErrorFormat(CultureInfo
.InvariantCulture
, format
, args
);
688 /// Logs a formatted message string with the <see cref="Level.Error"/> level.
690 /// <param name="format">A String containing zero or more format items</param>
691 /// <param name="arg0">An Object to format</param>
694 /// The message is formatted using the <c>String.Format</c> method. See
695 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
696 /// of the formatting.
699 /// This method does not take an <see cref="Exception"/> object to include in the
700 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/>
704 /// <seealso cref="Error(object)"/>
705 /// <seealso cref="IsErrorEnabled"/>
706 public static void ErrorFormat(string format
, object arg0
) {
707 facade
.ErrorFormat(format
, arg0
);
711 /// Logs a formatted message string with the <see cref="Level.Error"/> level.
713 /// <param name="format">A String containing zero or more format items</param>
714 /// <param name="arg0">An Object to format</param>
715 /// <param name="arg1">An Object to format</param>
718 /// The message is formatted using the <c>String.Format</c> method. See
719 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
720 /// of the formatting.
723 /// This method does not take an <see cref="Exception"/> object to include in the
724 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/>
728 /// <seealso cref="Error(object)"/>
729 /// <seealso cref="IsErrorEnabled"/>
730 public static void ErrorFormat(string format
, object arg0
, object arg1
) {
731 facade
.ErrorFormat(format
, arg0
, arg1
);
735 /// Logs a formatted message string with the <see cref="Level.Error"/> level.
737 /// <param name="format">A String containing zero or more format items</param>
738 /// <param name="arg0">An Object to format</param>
739 /// <param name="arg1">An Object to format</param>
740 /// <param name="arg2">An Object to format</param>
743 /// The message is formatted using the <c>String.Format</c> method. See
744 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
745 /// of the formatting.
748 /// This method does not take an <see cref="Exception"/> object to include in the
749 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/>
753 /// <seealso cref="Error(object)"/>
754 /// <seealso cref="IsErrorEnabled"/>
755 public static void ErrorFormat(string format
, object arg0
, object arg1
, object arg2
) {
756 facade
.ErrorFormat(format
, arg0
, arg1
, arg2
);
760 public static void ErrorFormat(IFormatProvider provider, string format, params object[] args) {
761 facade.ErrorFormat(provider, format, args);
765 /// <overloads>Log a message object with the <see cref="Level.Fatal"/> level.</overloads>
767 /// Log a message object with the <see cref="Level.Fatal"/> level.
771 /// This method first checks if this logger is <c>FATAL</c>
772 /// enabled by comparing the level of this logger with the
773 /// <see cref="Level.Fatal"/> level. If this logger is
774 /// <c>FATAL</c> enabled, then it converts the message object
775 /// (passed as parameter) to a string by invoking the appropriate
776 /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
777 /// proceeds to call all the registered appenders in this logger
778 /// and also higher in the hierarchy depending on the value of the
781 /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
782 /// to this method will print the name of the <see cref="Exception"/>
783 /// but no stack trace. To print a stack trace use the
784 /// <see cref="Fatal(object,Exception)"/> form instead.
787 /// <param name="message">The message object to log.</param>
788 /// <seealso cref="Fatal(object,Exception)"/>
789 /// <seealso cref="IsFatalEnabled"/>
790 public static void Fatal(object message
) {
791 facade
.Fatal(message
);
795 /// Log a message object with the <see cref="Level.Fatal"/> level including
796 /// the stack trace of the <see cref="Exception"/> passed
799 /// <param name="message">The message object to log.</param>
800 /// <param name="exception">The exception to log, including its stack trace.</param>
803 /// See the <see cref="Fatal(object)"/> form for more detailed information.
806 /// <seealso cref="Fatal(object)"/>
807 /// <seealso cref="IsFatalEnabled"/>
808 public static void Fatal(object message
, Exception exception
) {
809 facade
.Fatal(message
, exception
);
812 /// <overloads>Log a formatted message string with the <see cref="Level.Fatal"/> level.</overloads>
814 /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
816 /// <param name="format">A String containing zero or more format items</param>
817 /// <param name="args">An Object array containing zero or more objects to format</param>
820 /// The message is formatted using the <c>String.Format</c> method. See
821 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
822 /// of the formatting.
825 /// This method does not take an <see cref="Exception"/> object to include in the
826 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object)"/>
830 /// <seealso cref="Fatal(object,Exception)"/>
831 /// <seealso cref="IsFatalEnabled"/>
832 public static void FatalFormat(string format
, params object[] args
) {
833 facade
.FatalFormat(CultureInfo
.InvariantCulture
, format
, args
);
837 /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
839 /// <param name="format">A String containing zero or more format items</param>
840 /// <param name="arg0">An Object to format</param>
843 /// The message is formatted using the <c>String.Format</c> method. See
844 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
845 /// of the formatting.
848 /// This method does not take an <see cref="Exception"/> object to include in the
849 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/>
853 /// <seealso cref="Fatal(object)"/>
854 /// <seealso cref="IsFatalEnabled"/>
855 public static void FatalFormat(string format
, object arg0
) {
856 facade
.FatalFormat(format
, arg0
);
860 /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
862 /// <param name="format">A String containing zero or more format items</param>
863 /// <param name="arg0">An Object to format</param>
864 /// <param name="arg1">An Object to format</param>
867 /// The message is formatted using the <c>String.Format</c> method. See
868 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
869 /// of the formatting.
872 /// This method does not take an <see cref="Exception"/> object to include in the
873 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/>
877 /// <seealso cref="Fatal(object)"/>
878 /// <seealso cref="IsFatalEnabled"/>
879 public static void FatalFormat(string format
, object arg0
, object arg1
) {
880 facade
.FatalFormat(format
, arg0
, arg1
);
884 /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
886 /// <param name="format">A String containing zero or more format items</param>
887 /// <param name="arg0">An Object to format</param>
888 /// <param name="arg1">An Object to format</param>
889 /// <param name="arg2">An Object to format</param>
892 /// The message is formatted using the <c>String.Format</c> method. See
893 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
894 /// of the formatting.
897 /// This method does not take an <see cref="Exception"/> object to include in the
898 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/>
902 /// <seealso cref="Fatal(object)"/>
903 /// <seealso cref="IsFatalEnabled"/>
904 public static void FatalFormat(string format
, object arg0
, object arg1
, object arg2
) {
905 facade
.FatalFormat(format
, arg0
, arg1
, arg2
);
909 public static void FatalFormat(IFormatProvider provider, string format, params object[] args) {
910 facade.FatalFormat(provider, format, args);
917 /// Creates an additional logger on demand for a subsection of the application.
919 /// <param name="name">A name that will be included in the log file.</param>
920 /// <returns>The <see cref="ILog"/> instance created with the given name.</returns>
921 internal static ILog
Create(string name
) {
922 if (String
.IsNullOrEmpty(name
)) {
923 throw new ArgumentNullException("name");
926 return InitializeFacade(name
);
930 /// Creates an additional logger on demand for a subsection of the application.
932 /// <param name="type">A type whose full name that will be included in the log file.</param>
933 /// <returns>The <see cref="ILog"/> instance created with the given type name.</returns>
934 internal static ILog
Create(Type type
) {
936 throw new ArgumentNullException("type");
939 return Create(type
.FullName
);
943 /// Discovers the presence of Log4net.dll and other logging mechanisms
944 /// and returns the best available logger.
946 /// <param name="name">The name of the log to initialize.</param>
947 /// <returns>The <see cref="ILog"/> instance of the logger to use.</returns>
948 private static ILog
InitializeFacade(string name
) {
949 ILog result
= Log4NetLogger
.Initialize(name
) ?? TraceLogger
.Initialize(name
) ?? NoOpLogger
.Initialize();
950 result
.Info(Util
.LibraryVersion
);