1 //-----------------------------------------------------------------------
2 // <copyright file="Logger.cs" company="Andrew Arnott">
3 // Copyright (c) Andrew Arnott. All rights reserved.
5 //-----------------------------------------------------------------------
7 namespace YOURLIBNAME
{
9 using System
.Globalization
;
11 using YOURLIBNAME
.Loggers
;
14 /// A general logger for the entire YOURLIBNAME 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 for the duration of the appdomain.
25 private static ILog facade
= InitializeFacade();
28 //// Although this static class doesn't literally implement the ILog interface,
29 //// we implement (mostly) all the same methods in a static way.
32 /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Debug"/> level.
35 /// <c>true</c> if this logger is enabled for <see cref="Level.Debug"/> events, <c>false</c> otherwise.
39 /// This function is intended to lessen the computational cost of
40 /// disabled log debug statements.
42 /// <para> For some ILog interface <c>log</c>, when you write:</para>
44 /// log.Debug("This is entry number: " + i );
47 /// You incur the cost constructing the message, string construction and concatenation in
48 /// this case, regardless of whether the message is logged or not.
51 /// If you are worried about speed (who isn't), then you should write:
54 /// if (log.IsDebugEnabled)
56 /// log.Debug("This is entry number: " + i );
60 /// This way you will not incur the cost of parameter
61 /// construction if debugging is disabled for <c>log</c>. On
62 /// the other hand, if the <c>log</c> is debug enabled, you
63 /// will incur the cost of evaluating whether the logger is debug
64 /// enabled twice. Once in <see cref="IsDebugEnabled"/> and once in
65 /// the <see cref="Debug(object)"/>. This is an insignificant overhead
66 /// since evaluating a logger takes about 1% of the time it
67 /// takes to actually log. This is the preferred style of logging.
69 /// <para>Alternatively if your logger is available statically then the is debug
70 /// enabled state can be stored in a static variable like this:
73 /// private static readonly bool isDebugEnabled = log.IsDebugEnabled;
76 /// Then when you come to log you can write:
79 /// if (isDebugEnabled)
81 /// log.Debug("This is entry number: " + i );
85 /// This way the debug enabled state is only queried once
86 /// when the class is loaded. Using a <c>private static readonly</c>
87 /// variable is the most efficient because it is a run time constant
88 /// and can be heavily optimized by the JIT compiler.
91 /// Of course if you use a static readonly variable to
92 /// hold the enabled state of the logger then you cannot
93 /// change the enabled state at runtime to vary the logging
94 /// that is produced. You have to decide if you need absolute
95 /// speed or runtime flexibility.
98 /// <seealso cref="Debug(object)"/>
99 /// <seealso cref="DebugFormat(string, object[])"/>
100 public static bool IsDebugEnabled
{
101 get { return facade.IsDebugEnabled; }
105 /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Info"/> level.
108 /// <c>true</c> if this logger is enabled for <see cref="Level.Info"/> events, <c>false</c> otherwise.
111 /// For more information see <see cref="ILog.IsDebugEnabled"/>.
113 /// <seealso cref="Info(object)"/>
114 /// <seealso cref="InfoFormat(string, object[])"/>
115 /// <seealso cref="ILog.IsDebugEnabled"/>
116 public static bool IsInfoEnabled
{
117 get { return facade.IsInfoEnabled; }
121 /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Warn"/> level.
124 /// <c>true</c> if this logger is enabled for <see cref="Level.Warn"/> events, <c>false</c> otherwise.
127 /// For more information see <see cref="ILog.IsDebugEnabled"/>.
129 /// <seealso cref="Warn(object)"/>
130 /// <seealso cref="WarnFormat(string, object[])"/>
131 /// <seealso cref="ILog.IsDebugEnabled"/>
132 public static bool IsWarnEnabled
{
133 get { return facade.IsWarnEnabled; }
137 /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Error"/> level.
140 /// <c>true</c> if this logger is enabled for <see cref="Level.Error"/> events, <c>false</c> otherwise.
143 /// For more information see <see cref="ILog.IsDebugEnabled"/>.
145 /// <seealso cref="Error(object)"/>
146 /// <seealso cref="ErrorFormat(string, object[])"/>
147 /// <seealso cref="ILog.IsDebugEnabled"/>
148 public static bool IsErrorEnabled
{
149 get { return facade.IsErrorEnabled; }
153 /// Gets a value indicating whether this logger is enabled for the <see cref="Level.Fatal"/> level.
156 /// <c>true</c> if this logger is enabled for <see cref="Level.Fatal"/> events, <c>false</c> otherwise.
159 /// For more information see <see cref="ILog.IsDebugEnabled"/>.
161 /// <seealso cref="Fatal(object)"/>
162 /// <seealso cref="FatalFormat(string, object[])"/>
163 /// <seealso cref="ILog.IsDebugEnabled"/>
164 public static bool IsFatalEnabled
{
165 get { return facade.IsFatalEnabled; }
168 /// <overloads>Log a message object with the <see cref="Level.Debug"/> level.</overloads>
170 /// Log a message object with the <see cref="Level.Debug"/> level.
172 /// <param name="message">The message object to log.</param>
175 /// This method first checks if this logger is <c>DEBUG</c>
176 /// enabled by comparing the level of this logger with the
177 /// <see cref="Level.Debug"/> level. If this logger is
178 /// <c>DEBUG</c> enabled, then it converts the message object
179 /// (passed as parameter) to a string by invoking the appropriate
180 /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
181 /// proceeds to call all the registered appenders in this logger
182 /// and also higher in the hierarchy depending on the value of
183 /// the additivity flag.
185 /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
186 /// to this method will print the name of the <see cref="Exception"/>
187 /// but no stack trace. To print a stack trace use the
188 /// <see cref="Debug(object,Exception)"/> form instead.
191 /// <seealso cref="Debug(object,Exception)"/>
192 /// <seealso cref="IsDebugEnabled"/>
193 public static void Debug(object message
) {
194 facade
.Debug(message
);
198 /// Log a message object with the <see cref="Level.Debug"/> level including
199 /// the stack trace of the <see cref="Exception"/> passed
202 /// <param name="message">The message object to log.</param>
203 /// <param name="exception">The exception to log, including its stack trace.</param>
206 /// See the <see cref="Debug(object)"/> form for more detailed information.
209 /// <seealso cref="Debug(object)"/>
210 /// <seealso cref="IsDebugEnabled"/>
211 public static void Debug(object message
, Exception exception
) {
212 facade
.Debug(message
, exception
);
215 /// <overloads>Log a formatted string with the <see cref="Level.Debug"/> level.</overloads>
217 /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
219 /// <param name="format">A String containing zero or more format items</param>
220 /// <param name="args">An Object array containing zero or more objects to format</param>
223 /// The message is formatted using the <c>String.Format</c> method. See
224 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
225 /// of the formatting.
228 /// This method does not take an <see cref="Exception"/> object to include in the
229 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
233 /// <seealso cref="Debug(object)"/>
234 /// <seealso cref="IsDebugEnabled"/>
235 public static void DebugFormat(string format
, params object[] args
) {
236 facade
.DebugFormat(CultureInfo
.InvariantCulture
, format
, args
);
240 /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
242 /// <param name="format">A String containing zero or more format items</param>
243 /// <param name="arg0">An Object to format</param>
246 /// The message is formatted using the <c>String.Format</c> method. See
247 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
248 /// of the formatting.
251 /// This method does not take an <see cref="Exception"/> object to include in the
252 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
256 /// <seealso cref="Debug(object)"/>
257 /// <seealso cref="IsDebugEnabled"/>
258 public static void DebugFormat(string format
, object arg0
) {
259 facade
.DebugFormat(format
, arg0
);
263 /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
265 /// <param name="format">A String containing zero or more format items</param>
266 /// <param name="arg0">An Object to format</param>
267 /// <param name="arg1">An Object to format</param>
270 /// The message is formatted using the <c>String.Format</c> method. See
271 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
272 /// of the formatting.
275 /// This method does not take an <see cref="Exception"/> object to include in the
276 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
280 /// <seealso cref="Debug(object)"/>
281 /// <seealso cref="IsDebugEnabled"/>
282 public static void DebugFormat(string format
, object arg0
, object arg1
) {
283 facade
.DebugFormat(format
, arg0
, arg1
);
287 /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
289 /// <param name="format">A String containing zero or more format items</param>
290 /// <param name="arg0">An Object to format</param>
291 /// <param name="arg1">An Object to format</param>
292 /// <param name="arg2">An Object to format</param>
295 /// The message is formatted using the <c>String.Format</c> method. See
296 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
297 /// of the formatting.
300 /// This method does not take an <see cref="Exception"/> object to include in the
301 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
305 /// <seealso cref="Debug(object)"/>
306 /// <seealso cref="IsDebugEnabled"/>
307 public static void DebugFormat(string format
, object arg0
, object arg1
, object arg2
) {
308 facade
.DebugFormat(format
, arg0
, arg1
, arg2
);
312 public static void DebugFormat(IFormatProvider provider, string format, params object[] args) {
313 facade.DebugFormat(provider, format, args);
317 /// <overloads>Log a message object with the <see cref="Level.Info"/> level.</overloads>
319 /// Logs a message object with the <see cref="Level.Info"/> level.
323 /// This method first checks if this logger is <c>INFO</c>
324 /// enabled by comparing the level of this logger with the
325 /// <see cref="Level.Info"/> level. If this logger is
326 /// <c>INFO</c> enabled, then it converts the message object
327 /// (passed as parameter) to a string by invoking the appropriate
328 /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
329 /// proceeds to call all the registered appenders in this logger
330 /// and also higher in the hierarchy depending on the value of the
333 /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
334 /// to this method will print the name of the <see cref="Exception"/>
335 /// but no stack trace. To print a stack trace use the
336 /// <see cref="Info(object,Exception)"/> form instead.
339 /// <param name="message">The message object to log.</param>
340 /// <seealso cref="Info(object,Exception)"/>
341 /// <seealso cref="IsInfoEnabled"/>
342 public static void Info(object message
) {
343 facade
.Info(message
);
347 /// Logs a message object with the <c>INFO</c> level including
348 /// the stack trace of the <see cref="Exception"/> passed
351 /// <param name="message">The message object to log.</param>
352 /// <param name="exception">The exception to log, including its stack trace.</param>
355 /// See the <see cref="Info(object)"/> form for more detailed information.
358 /// <seealso cref="Info(object)"/>
359 /// <seealso cref="IsInfoEnabled"/>
360 public static void Info(object message
, Exception exception
) {
361 facade
.Info(message
, exception
);
364 /// <overloads>Log a formatted message string with the <see cref="Level.Info"/> level.</overloads>
366 /// Logs a formatted message string with the <see cref="Level.Info"/> level.
368 /// <param name="format">A String containing zero or more format items</param>
369 /// <param name="args">An Object array containing zero or more objects to format</param>
372 /// The message is formatted using the <c>String.Format</c> method. See
373 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
374 /// of the formatting.
377 /// This method does not take an <see cref="Exception"/> object to include in the
378 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object)"/>
382 /// <seealso cref="Info(object,Exception)"/>
383 /// <seealso cref="IsInfoEnabled"/>
384 public static void InfoFormat(string format
, params object[] args
) {
385 facade
.InfoFormat(CultureInfo
.InvariantCulture
, format
, args
);
389 /// Logs a formatted message string with the <see cref="Level.Info"/> level.
391 /// <param name="format">A String containing zero or more format items</param>
392 /// <param name="arg0">An Object to format</param>
395 /// The message is formatted using the <c>String.Format</c> method. See
396 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
397 /// of the formatting.
400 /// This method does not take an <see cref="Exception"/> object to include in the
401 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/>
405 /// <seealso cref="Info(object)"/>
406 /// <seealso cref="IsInfoEnabled"/>
407 public static void InfoFormat(string format
, object arg0
) {
408 facade
.InfoFormat(format
, arg0
);
412 /// Logs a formatted message string with the <see cref="Level.Info"/> level.
414 /// <param name="format">A String containing zero or more format items</param>
415 /// <param name="arg0">An Object to format</param>
416 /// <param name="arg1">An Object to format</param>
419 /// The message is formatted using the <c>String.Format</c> method. See
420 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
421 /// of the formatting.
424 /// This method does not take an <see cref="Exception"/> object to include in the
425 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/>
429 /// <seealso cref="Info(object)"/>
430 /// <seealso cref="IsInfoEnabled"/>
431 public static void InfoFormat(string format
, object arg0
, object arg1
) {
432 facade
.InfoFormat(format
, arg0
, arg1
);
436 /// Logs a formatted message string with the <see cref="Level.Info"/> level.
438 /// <param name="format">A String containing zero or more format items</param>
439 /// <param name="arg0">An Object to format</param>
440 /// <param name="arg1">An Object to format</param>
441 /// <param name="arg2">An Object to format</param>
444 /// The message is formatted using the <c>String.Format</c> method. See
445 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
446 /// of the formatting.
449 /// This method does not take an <see cref="Exception"/> object to include in the
450 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/>
454 /// <seealso cref="Info(object)"/>
455 /// <seealso cref="IsInfoEnabled"/>
456 public static void InfoFormat(string format
, object arg0
, object arg1
, object arg2
) {
457 facade
.InfoFormat(format
, arg0
, arg1
, arg2
);
461 public static void InfoFormat(IFormatProvider provider, string format, params object[] args) {
462 facade.InfoFormat(provider, format, args);
466 /// <overloads>Log a message object with the <see cref="Level.Warn"/> level.</overloads>
468 /// Log a message object with the <see cref="Level.Warn"/> level.
472 /// This method first checks if this logger is <c>WARN</c>
473 /// enabled by comparing the level of this logger with the
474 /// <see cref="Level.Warn"/> level. If this logger is
475 /// <c>WARN</c> enabled, then it converts the message object
476 /// (passed as parameter) to a string by invoking the appropriate
477 /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
478 /// proceeds to call all the registered appenders in this logger
479 /// and also higher in the hierarchy depending on the value of the
482 /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
483 /// to this method will print the name of the <see cref="Exception"/>
484 /// but no stack trace. To print a stack trace use the
485 /// <see cref="Warn(object,Exception)"/> form instead.
488 /// <param name="message">The message object to log.</param>
489 /// <seealso cref="Warn(object,Exception)"/>
490 /// <seealso cref="IsWarnEnabled"/>
491 public static void Warn(object message
) {
492 facade
.Warn(message
);
496 /// Log a message object with the <see cref="Level.Warn"/> level including
497 /// the stack trace of the <see cref="Exception"/> passed
500 /// <param name="message">The message object to log.</param>
501 /// <param name="exception">The exception to log, including its stack trace.</param>
504 /// See the <see cref="Warn(object)"/> form for more detailed information.
507 /// <seealso cref="Warn(object)"/>
508 /// <seealso cref="IsWarnEnabled"/>
509 public static void Warn(object message
, Exception exception
) {
510 facade
.Warn(message
, exception
);
513 /// <overloads>Log a formatted message string with the <see cref="Level.Warn"/> level.</overloads>
515 /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
517 /// <param name="format">A String containing zero or more format items</param>
518 /// <param name="args">An Object array containing zero or more objects to format</param>
521 /// The message is formatted using the <c>String.Format</c> method. See
522 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
523 /// of the formatting.
526 /// This method does not take an <see cref="Exception"/> object to include in the
527 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object)"/>
531 /// <seealso cref="Warn(object,Exception)"/>
532 /// <seealso cref="IsWarnEnabled"/>
533 public static void WarnFormat(string format
, params object[] args
) {
534 facade
.WarnFormat(CultureInfo
.InvariantCulture
, format
, args
);
538 /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
540 /// <param name="format">A String containing zero or more format items</param>
541 /// <param name="arg0">An Object to format</param>
544 /// The message is formatted using the <c>String.Format</c> method. See
545 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
546 /// of the formatting.
549 /// This method does not take an <see cref="Exception"/> object to include in the
550 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/>
554 /// <seealso cref="Warn(object)"/>
555 /// <seealso cref="IsWarnEnabled"/>
556 public static void WarnFormat(string format
, object arg0
) {
557 facade
.WarnFormat(format
, arg0
);
561 /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
563 /// <param name="format">A String containing zero or more format items</param>
564 /// <param name="arg0">An Object to format</param>
565 /// <param name="arg1">An Object to format</param>
568 /// The message is formatted using the <c>String.Format</c> method. See
569 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
570 /// of the formatting.
573 /// This method does not take an <see cref="Exception"/> object to include in the
574 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/>
578 /// <seealso cref="Warn(object)"/>
579 /// <seealso cref="IsWarnEnabled"/>
580 public static void WarnFormat(string format
, object arg0
, object arg1
) {
581 facade
.WarnFormat(format
, arg0
, arg1
);
585 /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
587 /// <param name="format">A String containing zero or more format items</param>
588 /// <param name="arg0">An Object to format</param>
589 /// <param name="arg1">An Object to format</param>
590 /// <param name="arg2">An Object to format</param>
593 /// The message is formatted using the <c>String.Format</c> method. See
594 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
595 /// of the formatting.
598 /// This method does not take an <see cref="Exception"/> object to include in the
599 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/>
603 /// <seealso cref="Warn(object)"/>
604 /// <seealso cref="IsWarnEnabled"/>
605 public static void WarnFormat(string format
, object arg0
, object arg1
, object arg2
) {
606 facade
.WarnFormat(format
, arg0
, arg1
, arg2
);
610 public static void WarnFormat(IFormatProvider provider, string format, params object[] args) {
611 facade.WarnFormat(provider, format, args);
615 /// <overloads>Log a message object with the <see cref="Level.Error"/> level.</overloads>
617 /// Logs a message object with the <see cref="Level.Error"/> level.
619 /// <param name="message">The message object to log.</param>
622 /// This method first checks if this logger is <c>ERROR</c>
623 /// enabled by comparing the level of this logger with the
624 /// <see cref="Level.Error"/> level. If this logger is
625 /// <c>ERROR</c> enabled, then it converts the message object
626 /// (passed as parameter) to a string by invoking the appropriate
627 /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
628 /// proceeds to call all the registered appenders in this logger
629 /// and also higher in the hierarchy depending on the value of the
632 /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
633 /// to this method will print the name of the <see cref="Exception"/>
634 /// but no stack trace. To print a stack trace use the
635 /// <see cref="Error(object,Exception)"/> form instead.
638 /// <seealso cref="Error(object,Exception)"/>
639 /// <seealso cref="IsErrorEnabled"/>
640 public static void Error(object message
) {
641 facade
.Error(message
);
645 /// Log a message object with the <see cref="Level.Error"/> level including
646 /// the stack trace of the <see cref="Exception"/> passed
649 /// <param name="message">The message object to log.</param>
650 /// <param name="exception">The exception to log, including its stack trace.</param>
653 /// See the <see cref="Error(object)"/> form for more detailed information.
656 /// <seealso cref="Error(object)"/>
657 /// <seealso cref="IsErrorEnabled"/>
658 public static void Error(object message
, Exception exception
) {
659 facade
.Error(message
, exception
);
662 /// <overloads>Log a formatted message string with the <see cref="Level.Error"/> level.</overloads>
664 /// Logs a formatted message string with the <see cref="Level.Error"/> level.
666 /// <param name="format">A String containing zero or more format items</param>
667 /// <param name="args">An Object array containing zero or more objects to format</param>
670 /// The message is formatted using the <c>String.Format</c> method. See
671 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
672 /// of the formatting.
675 /// This method does not take an <see cref="Exception"/> object to include in the
676 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object)"/>
680 /// <seealso cref="Error(object,Exception)"/>
681 /// <seealso cref="IsErrorEnabled"/>
682 public static void ErrorFormat(string format
, params object[] args
) {
683 facade
.ErrorFormat(CultureInfo
.InvariantCulture
, format
, args
);
687 /// Logs a formatted message string with the <see cref="Level.Error"/> level.
689 /// <param name="format">A String containing zero or more format items</param>
690 /// <param name="arg0">An Object to format</param>
693 /// The message is formatted using the <c>String.Format</c> method. See
694 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
695 /// of the formatting.
698 /// This method does not take an <see cref="Exception"/> object to include in the
699 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/>
703 /// <seealso cref="Error(object)"/>
704 /// <seealso cref="IsErrorEnabled"/>
705 public static void ErrorFormat(string format
, object arg0
) {
706 facade
.ErrorFormat(format
, arg0
);
710 /// Logs a formatted message string with the <see cref="Level.Error"/> level.
712 /// <param name="format">A String containing zero or more format items</param>
713 /// <param name="arg0">An Object to format</param>
714 /// <param name="arg1">An Object to format</param>
717 /// The message is formatted using the <c>String.Format</c> method. See
718 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
719 /// of the formatting.
722 /// This method does not take an <see cref="Exception"/> object to include in the
723 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/>
727 /// <seealso cref="Error(object)"/>
728 /// <seealso cref="IsErrorEnabled"/>
729 public static void ErrorFormat(string format
, object arg0
, object arg1
) {
730 facade
.ErrorFormat(format
, arg0
, arg1
);
734 /// Logs a formatted message string with the <see cref="Level.Error"/> level.
736 /// <param name="format">A String containing zero or more format items</param>
737 /// <param name="arg0">An Object to format</param>
738 /// <param name="arg1">An Object to format</param>
739 /// <param name="arg2">An Object to format</param>
742 /// The message is formatted using the <c>String.Format</c> method. See
743 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
744 /// of the formatting.
747 /// This method does not take an <see cref="Exception"/> object to include in the
748 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/>
752 /// <seealso cref="Error(object)"/>
753 /// <seealso cref="IsErrorEnabled"/>
754 public static void ErrorFormat(string format
, object arg0
, object arg1
, object arg2
) {
755 facade
.ErrorFormat(format
, arg0
, arg1
, arg2
);
759 public static void ErrorFormat(IFormatProvider provider, string format, params object[] args) {
760 facade.ErrorFormat(provider, format, args);
764 /// <overloads>Log a message object with the <see cref="Level.Fatal"/> level.</overloads>
766 /// Log a message object with the <see cref="Level.Fatal"/> level.
770 /// This method first checks if this logger is <c>FATAL</c>
771 /// enabled by comparing the level of this logger with the
772 /// <see cref="Level.Fatal"/> level. If this logger is
773 /// <c>FATAL</c> enabled, then it converts the message object
774 /// (passed as parameter) to a string by invoking the appropriate
775 /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
776 /// proceeds to call all the registered appenders in this logger
777 /// and also higher in the hierarchy depending on the value of the
780 /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
781 /// to this method will print the name of the <see cref="Exception"/>
782 /// but no stack trace. To print a stack trace use the
783 /// <see cref="Fatal(object,Exception)"/> form instead.
786 /// <param name="message">The message object to log.</param>
787 /// <seealso cref="Fatal(object,Exception)"/>
788 /// <seealso cref="IsFatalEnabled"/>
789 public static void Fatal(object message
) {
790 facade
.Fatal(message
);
794 /// Log a message object with the <see cref="Level.Fatal"/> level including
795 /// the stack trace of the <see cref="Exception"/> passed
798 /// <param name="message">The message object to log.</param>
799 /// <param name="exception">The exception to log, including its stack trace.</param>
802 /// See the <see cref="Fatal(object)"/> form for more detailed information.
805 /// <seealso cref="Fatal(object)"/>
806 /// <seealso cref="IsFatalEnabled"/>
807 public static void Fatal(object message
, Exception exception
) {
808 facade
.Fatal(message
, exception
);
811 /// <overloads>Log a formatted message string with the <see cref="Level.Fatal"/> level.</overloads>
813 /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
815 /// <param name="format">A String containing zero or more format items</param>
816 /// <param name="args">An Object array containing zero or more objects to format</param>
819 /// The message is formatted using the <c>String.Format</c> method. See
820 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
821 /// of the formatting.
824 /// This method does not take an <see cref="Exception"/> object to include in the
825 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object)"/>
829 /// <seealso cref="Fatal(object,Exception)"/>
830 /// <seealso cref="IsFatalEnabled"/>
831 public static void FatalFormat(string format
, params object[] args
) {
832 facade
.FatalFormat(CultureInfo
.InvariantCulture
, format
, args
);
836 /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
838 /// <param name="format">A String containing zero or more format items</param>
839 /// <param name="arg0">An Object to format</param>
842 /// The message is formatted using the <c>String.Format</c> method. See
843 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
844 /// of the formatting.
847 /// This method does not take an <see cref="Exception"/> object to include in the
848 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/>
852 /// <seealso cref="Fatal(object)"/>
853 /// <seealso cref="IsFatalEnabled"/>
854 public static void FatalFormat(string format
, object arg0
) {
855 facade
.FatalFormat(format
, arg0
);
859 /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
861 /// <param name="format">A String containing zero or more format items</param>
862 /// <param name="arg0">An Object to format</param>
863 /// <param name="arg1">An Object to format</param>
866 /// The message is formatted using the <c>String.Format</c> method. See
867 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
868 /// of the formatting.
871 /// This method does not take an <see cref="Exception"/> object to include in the
872 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/>
876 /// <seealso cref="Fatal(object)"/>
877 /// <seealso cref="IsFatalEnabled"/>
878 public static void FatalFormat(string format
, object arg0
, object arg1
) {
879 facade
.FatalFormat(format
, arg0
, arg1
);
883 /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
885 /// <param name="format">A String containing zero or more format items</param>
886 /// <param name="arg0">An Object to format</param>
887 /// <param name="arg1">An Object to format</param>
888 /// <param name="arg2">An Object to format</param>
891 /// The message is formatted using the <c>String.Format</c> method. See
892 /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
893 /// of the formatting.
896 /// This method does not take an <see cref="Exception"/> object to include in the
897 /// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/>
901 /// <seealso cref="Fatal(object)"/>
902 /// <seealso cref="IsFatalEnabled"/>
903 public static void FatalFormat(string format
, object arg0
, object arg1
, object arg2
) {
904 facade
.FatalFormat(format
, arg0
, arg1
, arg2
);
908 public static void FatalFormat(IFormatProvider provider, string format, params object[] args) {
909 facade.FatalFormat(provider, format, args);
916 /// Discovers the presence of Log4net.dll and other logging mechanisms
917 /// and returns the best available logger.
919 /// <returns>The <see cref="ILog"/> instance of the logger to use.</returns>
920 private static ILog
InitializeFacade() {
921 ILog result
= Log4NetLogger
.Initialize() ?? TraceLogger
.Initialize() ?? NoOpLogger
.Initialize();
922 result
.Info(Util
.LibraryVersion
);