1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
|
//-----------------------------------------------------------------------
// <copyright file="Logger.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOAuth {
using System;
using System.Globalization;
using DotNetOAuth.Loggers;
using log4net.Core;
/// <summary>
/// A general logger for the entire DotNetOAuth library.
/// </summary>
/// <remarks>
/// Because this logger is intended for use with non-localized strings, the
/// overloads that take <see cref="CultureInfo"/> have been removed, and
/// <see cref="CultureInfo.InvariantCulture"/> is used implicitly.
/// </remarks>
internal static class Logger {
/// <summary>
/// The <see cref="ILog"/> instance that is to be used for the duration of the appdomain.
/// </summary>
private static ILog facade = InitializeFacade();
#region ILog Members
//// Although this static class doesn't literally implement the ILog interface,
//// we implement (mostly) all the same methods in a static way.
/// <summary>
/// Gets a value indicating whether this logger is enabled for the <see cref="Level.Debug"/> level.
/// </summary>
/// <value>
/// <c>true</c> if this logger is enabled for <see cref="Level.Debug"/> events, <c>false</c> otherwise.
/// </value>
/// <remarks>
/// <para>
/// This function is intended to lessen the computational cost of
/// disabled log debug statements.
/// </para>
/// <para> For some ILog interface <c>log</c>, when you write:</para>
/// <code lang="C#">
/// log.Debug("This is entry number: " + i );
/// </code>
/// <para>
/// You incur the cost constructing the message, string construction and concatenation in
/// this case, regardless of whether the message is logged or not.
/// </para>
/// <para>
/// If you are worried about speed (who isn't), then you should write:
/// </para>
/// <code lang="C#">
/// if (log.IsDebugEnabled)
/// {
/// log.Debug("This is entry number: " + i );
/// }
/// </code>
/// <para>
/// This way you will not incur the cost of parameter
/// construction if debugging is disabled for <c>log</c>. On
/// the other hand, if the <c>log</c> is debug enabled, you
/// will incur the cost of evaluating whether the logger is debug
/// enabled twice. Once in <see cref="IsDebugEnabled"/> and once in
/// the <see cref="Debug(object)"/>. This is an insignificant overhead
/// since evaluating a logger takes about 1% of the time it
/// takes to actually log. This is the preferred style of logging.
/// </para>
/// <para>Alternatively if your logger is available statically then the is debug
/// enabled state can be stored in a static variable like this:
/// </para>
/// <code lang="C#">
/// private static readonly bool isDebugEnabled = log.IsDebugEnabled;
/// </code>
/// <para>
/// Then when you come to log you can write:
/// </para>
/// <code lang="C#">
/// if (isDebugEnabled)
/// {
/// log.Debug("This is entry number: " + i );
/// }
/// </code>
/// <para>
/// This way the debug enabled state is only queried once
/// when the class is loaded. Using a <c>private static readonly</c>
/// variable is the most efficient because it is a run time constant
/// and can be heavily optimized by the JIT compiler.
/// </para>
/// <para>
/// Of course if you use a static readonly variable to
/// hold the enabled state of the logger then you cannot
/// change the enabled state at runtime to vary the logging
/// that is produced. You have to decide if you need absolute
/// speed or runtime flexibility.
/// </para>
/// </remarks>
/// <seealso cref="Debug(object)"/>
/// <seealso cref="DebugFormat(string, object[])"/>
public static bool IsDebugEnabled {
get { return facade.IsDebugEnabled; }
}
/// <summary>
/// Gets a value indicating whether this logger is enabled for the <see cref="Level.Info"/> level.
/// </summary>
/// <value>
/// <c>true</c> if this logger is enabled for <see cref="Level.Info"/> events, <c>false</c> otherwise.
/// </value>
/// <remarks>
/// For more information see <see cref="ILog.IsDebugEnabled"/>.
/// </remarks>
/// <seealso cref="Info(object)"/>
/// <seealso cref="InfoFormat(string, object[])"/>
/// <seealso cref="ILog.IsDebugEnabled"/>
public static bool IsInfoEnabled {
get { return facade.IsInfoEnabled; }
}
/// <summary>
/// Gets a value indicating whether this logger is enabled for the <see cref="Level.Warn"/> level.
/// </summary>
/// <value>
/// <c>true</c> if this logger is enabled for <see cref="Level.Warn"/> events, <c>false</c> otherwise.
/// </value>
/// <remarks>
/// For more information see <see cref="ILog.IsDebugEnabled"/>.
/// </remarks>
/// <seealso cref="Warn(object)"/>
/// <seealso cref="WarnFormat(string, object[])"/>
/// <seealso cref="ILog.IsDebugEnabled"/>
public static bool IsWarnEnabled {
get { return facade.IsWarnEnabled; }
}
/// <summary>
/// Gets a value indicating whether this logger is enabled for the <see cref="Level.Error"/> level.
/// </summary>
/// <value>
/// <c>true</c> if this logger is enabled for <see cref="Level.Error"/> events, <c>false</c> otherwise.
/// </value>
/// <remarks>
/// For more information see <see cref="ILog.IsDebugEnabled"/>.
/// </remarks>
/// <seealso cref="Error(object)"/>
/// <seealso cref="ErrorFormat(string, object[])"/>
/// <seealso cref="ILog.IsDebugEnabled"/>
public static bool IsErrorEnabled {
get { return facade.IsErrorEnabled; }
}
/// <summary>
/// Gets a value indicating whether this logger is enabled for the <see cref="Level.Fatal"/> level.
/// </summary>
/// <value>
/// <c>true</c> if this logger is enabled for <see cref="Level.Fatal"/> events, <c>false</c> otherwise.
/// </value>
/// <remarks>
/// For more information see <see cref="ILog.IsDebugEnabled"/>.
/// </remarks>
/// <seealso cref="Fatal(object)"/>
/// <seealso cref="FatalFormat(string, object[])"/>
/// <seealso cref="ILog.IsDebugEnabled"/>
public static bool IsFatalEnabled {
get { return facade.IsFatalEnabled; }
}
/// <overloads>Log a message object with the <see cref="Level.Debug"/> level.</overloads>
/// <summary>
/// Log a message object with the <see cref="Level.Debug"/> level.
/// </summary>
/// <param name="message">The message object to log.</param>
/// <remarks>
/// <para>
/// This method first checks if this logger is <c>DEBUG</c>
/// enabled by comparing the level of this logger with the
/// <see cref="Level.Debug"/> level. If this logger is
/// <c>DEBUG</c> enabled, then it converts the message object
/// (passed as parameter) to a string by invoking the appropriate
/// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
/// proceeds to call all the registered appenders in this logger
/// and also higher in the hierarchy depending on the value of
/// the additivity flag.
/// </para>
/// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
/// to this method will print the name of the <see cref="Exception"/>
/// but no stack trace. To print a stack trace use the
/// <see cref="Debug(object,Exception)"/> form instead.
/// </para>
/// </remarks>
/// <seealso cref="Debug(object,Exception)"/>
/// <seealso cref="IsDebugEnabled"/>
public static void Debug(object message) {
facade.Debug(message);
}
/// <summary>
/// Log a message object with the <see cref="Level.Debug"/> level including
/// the stack trace of the <see cref="Exception"/> passed
/// as a parameter.
/// </summary>
/// <param name="message">The message object to log.</param>
/// <param name="exception">The exception to log, including its stack trace.</param>
/// <remarks>
/// <para>
/// See the <see cref="Debug(object)"/> form for more detailed information.
/// </para>
/// </remarks>
/// <seealso cref="Debug(object)"/>
/// <seealso cref="IsDebugEnabled"/>
public static void Debug(object message, Exception exception) {
facade.Debug(message, exception);
}
/// <overloads>Log a formatted string with the <see cref="Level.Debug"/> level.</overloads>
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Debug"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="args">An Object array containing zero or more objects to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Debug(object)"/>
/// <seealso cref="IsDebugEnabled"/>
public static void DebugFormat(string format, params object[] args) {
facade.DebugFormat(CultureInfo.InvariantCulture, format, args);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Debug"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Debug(object)"/>
/// <seealso cref="IsDebugEnabled"/>
public static void DebugFormat(string format, object arg0) {
facade.DebugFormat(format, arg0);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Debug"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <param name="arg1">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Debug(object)"/>
/// <seealso cref="IsDebugEnabled"/>
public static void DebugFormat(string format, object arg0, object arg1) {
facade.DebugFormat(format, arg0, arg1);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Debug"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <param name="arg1">An Object to format</param>
/// <param name="arg2">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Debug(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Debug(object)"/>
/// <seealso cref="IsDebugEnabled"/>
public static void DebugFormat(string format, object arg0, object arg1, object arg2) {
facade.DebugFormat(format, arg0, arg1, arg2);
}
/*
public static void DebugFormat(IFormatProvider provider, string format, params object[] args) {
facade.DebugFormat(provider, format, args);
}
*/
/// <overloads>Log a message object with the <see cref="Level.Info"/> level.</overloads>
/// <summary>
/// Logs a message object with the <see cref="Level.Info"/> level.
/// </summary>
/// <remarks>
/// <para>
/// This method first checks if this logger is <c>INFO</c>
/// enabled by comparing the level of this logger with the
/// <see cref="Level.Info"/> level. If this logger is
/// <c>INFO</c> enabled, then it converts the message object
/// (passed as parameter) to a string by invoking the appropriate
/// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
/// proceeds to call all the registered appenders in this logger
/// and also higher in the hierarchy depending on the value of the
/// additivity flag.
/// </para>
/// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
/// to this method will print the name of the <see cref="Exception"/>
/// but no stack trace. To print a stack trace use the
/// <see cref="Info(object,Exception)"/> form instead.
/// </para>
/// </remarks>
/// <param name="message">The message object to log.</param>
/// <seealso cref="Info(object,Exception)"/>
/// <seealso cref="IsInfoEnabled"/>
public static void Info(object message) {
facade.Info(message);
}
/// <summary>
/// Logs a message object with the <c>INFO</c> level including
/// the stack trace of the <see cref="Exception"/> passed
/// as a parameter.
/// </summary>
/// <param name="message">The message object to log.</param>
/// <param name="exception">The exception to log, including its stack trace.</param>
/// <remarks>
/// <para>
/// See the <see cref="Info(object)"/> form for more detailed information.
/// </para>
/// </remarks>
/// <seealso cref="Info(object)"/>
/// <seealso cref="IsInfoEnabled"/>
public static void Info(object message, Exception exception) {
facade.Info(message, exception);
}
/// <overloads>Log a formatted message string with the <see cref="Level.Info"/> level.</overloads>
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Info"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="args">An Object array containing zero or more objects to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Info(object,Exception)"/>
/// <seealso cref="IsInfoEnabled"/>
public static void InfoFormat(string format, params object[] args) {
facade.InfoFormat(CultureInfo.InvariantCulture, format, args);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Info"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Info(object)"/>
/// <seealso cref="IsInfoEnabled"/>
public static void InfoFormat(string format, object arg0) {
facade.InfoFormat(format, arg0);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Info"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <param name="arg1">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Info(object)"/>
/// <seealso cref="IsInfoEnabled"/>
public static void InfoFormat(string format, object arg0, object arg1) {
facade.InfoFormat(format, arg0, arg1);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Info"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <param name="arg1">An Object to format</param>
/// <param name="arg2">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Info(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Info(object)"/>
/// <seealso cref="IsInfoEnabled"/>
public static void InfoFormat(string format, object arg0, object arg1, object arg2) {
facade.InfoFormat(format, arg0, arg1, arg2);
}
/*
public static void InfoFormat(IFormatProvider provider, string format, params object[] args) {
facade.InfoFormat(provider, format, args);
}
*/
/// <overloads>Log a message object with the <see cref="Level.Warn"/> level.</overloads>
/// <summary>
/// Log a message object with the <see cref="Level.Warn"/> level.
/// </summary>
/// <remarks>
/// <para>
/// This method first checks if this logger is <c>WARN</c>
/// enabled by comparing the level of this logger with the
/// <see cref="Level.Warn"/> level. If this logger is
/// <c>WARN</c> enabled, then it converts the message object
/// (passed as parameter) to a string by invoking the appropriate
/// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
/// proceeds to call all the registered appenders in this logger
/// and also higher in the hierarchy depending on the value of the
/// additivity flag.
/// </para>
/// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
/// to this method will print the name of the <see cref="Exception"/>
/// but no stack trace. To print a stack trace use the
/// <see cref="Warn(object,Exception)"/> form instead.
/// </para>
/// </remarks>
/// <param name="message">The message object to log.</param>
/// <seealso cref="Warn(object,Exception)"/>
/// <seealso cref="IsWarnEnabled"/>
public static void Warn(object message) {
facade.Warn(message);
}
/// <summary>
/// Log a message object with the <see cref="Level.Warn"/> level including
/// the stack trace of the <see cref="Exception"/> passed
/// as a parameter.
/// </summary>
/// <param name="message">The message object to log.</param>
/// <param name="exception">The exception to log, including its stack trace.</param>
/// <remarks>
/// <para>
/// See the <see cref="Warn(object)"/> form for more detailed information.
/// </para>
/// </remarks>
/// <seealso cref="Warn(object)"/>
/// <seealso cref="IsWarnEnabled"/>
public static void Warn(object message, Exception exception) {
facade.Warn(message, exception);
}
/// <overloads>Log a formatted message string with the <see cref="Level.Warn"/> level.</overloads>
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Warn"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="args">An Object array containing zero or more objects to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Warn(object,Exception)"/>
/// <seealso cref="IsWarnEnabled"/>
public static void WarnFormat(string format, params object[] args) {
facade.WarnFormat(CultureInfo.InvariantCulture, format, args);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Warn"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Warn(object)"/>
/// <seealso cref="IsWarnEnabled"/>
public static void WarnFormat(string format, object arg0) {
facade.WarnFormat(format, arg0);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Warn"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <param name="arg1">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Warn(object)"/>
/// <seealso cref="IsWarnEnabled"/>
public static void WarnFormat(string format, object arg0, object arg1) {
facade.WarnFormat(format, arg0, arg1);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Warn"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <param name="arg1">An Object to format</param>
/// <param name="arg2">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Warn(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Warn(object)"/>
/// <seealso cref="IsWarnEnabled"/>
public static void WarnFormat(string format, object arg0, object arg1, object arg2) {
facade.WarnFormat(format, arg0, arg1, arg2);
}
/*
public static void WarnFormat(IFormatProvider provider, string format, params object[] args) {
facade.WarnFormat(provider, format, args);
}
*/
/// <overloads>Log a message object with the <see cref="Level.Error"/> level.</overloads>
/// <summary>
/// Logs a message object with the <see cref="Level.Error"/> level.
/// </summary>
/// <param name="message">The message object to log.</param>
/// <remarks>
/// <para>
/// This method first checks if this logger is <c>ERROR</c>
/// enabled by comparing the level of this logger with the
/// <see cref="Level.Error"/> level. If this logger is
/// <c>ERROR</c> enabled, then it converts the message object
/// (passed as parameter) to a string by invoking the appropriate
/// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
/// proceeds to call all the registered appenders in this logger
/// and also higher in the hierarchy depending on the value of the
/// additivity flag.
/// </para>
/// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
/// to this method will print the name of the <see cref="Exception"/>
/// but no stack trace. To print a stack trace use the
/// <see cref="Error(object,Exception)"/> form instead.
/// </para>
/// </remarks>
/// <seealso cref="Error(object,Exception)"/>
/// <seealso cref="IsErrorEnabled"/>
public static void Error(object message) {
facade.Error(message);
}
/// <summary>
/// Log a message object with the <see cref="Level.Error"/> level including
/// the stack trace of the <see cref="Exception"/> passed
/// as a parameter.
/// </summary>
/// <param name="message">The message object to log.</param>
/// <param name="exception">The exception to log, including its stack trace.</param>
/// <remarks>
/// <para>
/// See the <see cref="Error(object)"/> form for more detailed information.
/// </para>
/// </remarks>
/// <seealso cref="Error(object)"/>
/// <seealso cref="IsErrorEnabled"/>
public static void Error(object message, Exception exception) {
facade.Error(message, exception);
}
/// <overloads>Log a formatted message string with the <see cref="Level.Error"/> level.</overloads>
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Error"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="args">An Object array containing zero or more objects to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Error(object,Exception)"/>
/// <seealso cref="IsErrorEnabled"/>
public static void ErrorFormat(string format, params object[] args) {
facade.ErrorFormat(CultureInfo.InvariantCulture, format, args);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Error"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Error(object)"/>
/// <seealso cref="IsErrorEnabled"/>
public static void ErrorFormat(string format, object arg0) {
facade.ErrorFormat(format, arg0);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Error"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <param name="arg1">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Error(object)"/>
/// <seealso cref="IsErrorEnabled"/>
public static void ErrorFormat(string format, object arg0, object arg1) {
facade.ErrorFormat(format, arg0, arg1);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Error"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <param name="arg1">An Object to format</param>
/// <param name="arg2">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Error(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Error(object)"/>
/// <seealso cref="IsErrorEnabled"/>
public static void ErrorFormat(string format, object arg0, object arg1, object arg2) {
facade.ErrorFormat(format, arg0, arg1, arg2);
}
/*
public static void ErrorFormat(IFormatProvider provider, string format, params object[] args) {
facade.ErrorFormat(provider, format, args);
}
*/
/// <overloads>Log a message object with the <see cref="Level.Fatal"/> level.</overloads>
/// <summary>
/// Log a message object with the <see cref="Level.Fatal"/> level.
/// </summary>
/// <remarks>
/// <para>
/// This method first checks if this logger is <c>FATAL</c>
/// enabled by comparing the level of this logger with the
/// <see cref="Level.Fatal"/> level. If this logger is
/// <c>FATAL</c> enabled, then it converts the message object
/// (passed as parameter) to a string by invoking the appropriate
/// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
/// proceeds to call all the registered appenders in this logger
/// and also higher in the hierarchy depending on the value of the
/// additivity flag.
/// </para>
/// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
/// to this method will print the name of the <see cref="Exception"/>
/// but no stack trace. To print a stack trace use the
/// <see cref="Fatal(object,Exception)"/> form instead.
/// </para>
/// </remarks>
/// <param name="message">The message object to log.</param>
/// <seealso cref="Fatal(object,Exception)"/>
/// <seealso cref="IsFatalEnabled"/>
public static void Fatal(object message) {
facade.Fatal(message);
}
/// <summary>
/// Log a message object with the <see cref="Level.Fatal"/> level including
/// the stack trace of the <see cref="Exception"/> passed
/// as a parameter.
/// </summary>
/// <param name="message">The message object to log.</param>
/// <param name="exception">The exception to log, including its stack trace.</param>
/// <remarks>
/// <para>
/// See the <see cref="Fatal(object)"/> form for more detailed information.
/// </para>
/// </remarks>
/// <seealso cref="Fatal(object)"/>
/// <seealso cref="IsFatalEnabled"/>
public static void Fatal(object message, Exception exception) {
facade.Fatal(message, exception);
}
/// <overloads>Log a formatted message string with the <see cref="Level.Fatal"/> level.</overloads>
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="args">An Object array containing zero or more objects to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Fatal(object,Exception)"/>
/// <seealso cref="IsFatalEnabled"/>
public static void FatalFormat(string format, params object[] args) {
facade.FatalFormat(CultureInfo.InvariantCulture, format, args);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Fatal(object)"/>
/// <seealso cref="IsFatalEnabled"/>
public static void FatalFormat(string format, object arg0) {
facade.FatalFormat(format, arg0);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <param name="arg1">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Fatal(object)"/>
/// <seealso cref="IsFatalEnabled"/>
public static void FatalFormat(string format, object arg0, object arg1) {
facade.FatalFormat(format, arg0, arg1);
}
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="arg0">An Object to format</param>
/// <param name="arg1">An Object to format</param>
/// <param name="arg2">An Object to format</param>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="Exception"/> object to include in the
/// log event. To pass an <see cref="Exception"/> use one of the <see cref="Fatal(object,Exception)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="Fatal(object)"/>
/// <seealso cref="IsFatalEnabled"/>
public static void FatalFormat(string format, object arg0, object arg1, object arg2) {
facade.FatalFormat(format, arg0, arg1, arg2);
}
/*
public static void FatalFormat(IFormatProvider provider, string format, params object[] args) {
facade.FatalFormat(provider, format, args);
}
*/
#endregion
/// <summary>
/// Discovers the presence of Log4net.dll and other logging mechanisms
/// and returns the best available logger.
/// </summary>
/// <returns>The <see cref="ILog"/> instance of the logger to use.</returns>
private static ILog InitializeFacade() {
ILog result = Log4NetLogger.Initialize() ?? TraceLogger.Initialize() ?? NoOpLogger.Initialize();
result.Info(Util.LibraryVersion);
return result;
}
}
}
|