2using System.Collections.Generic;
3using System.Reflection;
12 public static class Log
14 private static Type[] alertExceptionTypes =
new Type[0];
15 private static bool alertExceptionTypesLocked =
false;
17 private readonly
static List<IEventSink> dynamicSinks =
new List<IEventSink>();
18 private static Type[] nestedExceptionTypes =
new Type[]
20 typeof(TargetInvocationException),
21 typeof(TypeInitializationException)
36 staticSinks = dynamicSinks.ToArray();
54 staticSinks = dynamicSinks.ToArray();
69 if (!typeof(
Exception).GetTypeInfo().IsAssignableFrom(ExceptionType.GetTypeInfo()))
74 if (Array.IndexOf(nestedExceptionTypes, ExceptionType) >= 0)
77 int c = nestedExceptionTypes.Length;
78 Type[] Result =
new Type[c + 1];
79 Array.Copy(nestedExceptionTypes, 0, Result, 0, c);
80 Result[c] = ExceptionType;
81 nestedExceptionTypes = Result;
96 if (Sink is IDisposable Disposable)
100 Disposable.Dispose();
111 h(
null, EventArgs.Empty);
138 if (hasReportedErrors)
140 lock (reportedErrors)
143 hasReportedErrors = reportedErrors.Count > 0;
149 lock (reportedErrors)
151 if (reportedErrors.TryGetValue(
EventSink, out
bool b) && b)
155 hasReportedErrors =
true;
161 if (!(
Event.ToAvoid is
null))
164 Event2.
Avoid(EventSink2);
175 private readonly
static Dictionary<IEventSink, bool> reportedErrors =
new Dictionary<IEventSink, bool>();
176 private static bool hasReportedErrors =
false;
177 private static readonly
char[] crlf =
new char[] {
'\r',
'\n' };
186 if (
string.IsNullOrEmpty(StackTrace))
190 StringBuilder Result =
new StringBuilder();
192 foreach (
string Row
in StackTrace.Split(crlf, StringSplitOptions.RemoveEmptyEntries))
194 if (Row.StartsWith(
" at System.") || (Row.StartsWith(
"--- ") && Row.EndsWith(
" ---")))
197 Result.AppendLine(Row);
200 return Result.ToString();
218 public static void Debug(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
219 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
221 Event(
new Event(
EventType.Debug, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
235 public static void Debug(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
236 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
238 Event(
new Event(
EventType.Debug, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
251 public static void Debug(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
252 string Facility, params KeyValuePair<string, object>[] Tags)
254 Event(
new Event(
EventType.Debug, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
266 public static void Debug(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
267 params KeyValuePair<string, object>[] Tags)
269 Event(
new Event(
EventType.Debug, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
280 public static void Debug(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
292 public static void Debug(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
303 public static void Debug(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
305 Event(
new Event(
EventType.Debug, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
313 public static void Debug(
string Message, params KeyValuePair<string, object>[] Tags)
315 Event(
new Event(
EventType.Debug, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
320 #region Informational
335 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
337 Event(
new Event(
EventType.Informational, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
352 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
354 Event(
new Event(
EventType.Informational, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
368 string Facility, params KeyValuePair<string, object>[] Tags)
370 Event(
new Event(
EventType.Informational, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
383 params KeyValuePair<string, object>[] Tags)
385 Event(
new Event(
EventType.Informational, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
396 public static void Informational(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
398 Event(
new Event(
EventType.Informational, Message, Object, Actor, EventId,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
408 public static void Informational(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
410 Event(
new Event(
EventType.Informational, Message, Object, Actor,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
419 public static void Informational(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
421 Event(
new Event(
EventType.Informational, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
429 public static void Informational(
string Message, params KeyValuePair<string, object>[] Tags)
431 Event(
new Event(
EventType.Informational, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
450 public static void Notice(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
451 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
453 Event(
new Event(
EventType.Notice, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
467 public static void Notice(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
468 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
470 Event(
new Event(
EventType.Notice, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
483 public static void Notice(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
484 string Facility, params KeyValuePair<string, object>[] Tags)
486 Event(
new Event(
EventType.Notice, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
498 public static void Notice(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
499 params KeyValuePair<string, object>[] Tags)
501 Event(
new Event(
EventType.Notice, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
512 public static void Notice(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
524 public static void Notice(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
535 public static void Notice(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
537 Event(
new Event(
EventType.Notice, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
545 public static void Notice(
string Message, params KeyValuePair<string, object>[] Tags)
547 Event(
new Event(
EventType.Notice, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
566 public static void Warning(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
567 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
569 Event(
new Event(
EventType.Warning, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
583 public static void Warning(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
584 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
586 Event(
new Event(
EventType.Warning, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
599 public static void Warning(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
600 string Facility, params KeyValuePair<string, object>[] Tags)
602 Event(
new Event(
EventType.Warning, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
614 public static void Warning(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
615 params KeyValuePair<string, object>[] Tags)
617 Event(
new Event(
EventType.Warning, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
628 public static void Warning(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
640 public static void Warning(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
651 public static void Warning(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
653 Event(
new Event(
EventType.Warning, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
661 public static void Warning(
string Message, params KeyValuePair<string, object>[] Tags)
663 Event(
new Event(
EventType.Warning, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
682 public static void Error(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
683 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
685 Event(
new Event(
EventType.Error, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
699 public static void Error(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
700 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
702 Event(
new Event(
EventType.Error, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
715 public static void Error(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
716 string Facility, params KeyValuePair<string, object>[] Tags)
718 Event(
new Event(
EventType.Error, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
730 public static void Error(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
731 params KeyValuePair<string, object>[] Tags)
733 Event(
new Event(
EventType.Error, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
744 public static void Error(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
756 public static void Error(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
767 public static void Error(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
769 Event(
new Event(
EventType.Error, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
777 public static void Error(
string Message, params KeyValuePair<string, object>[] Tags)
779 Event(
new Event(
EventType.Error, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
793 public static void Error(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
794 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
796 Event(
EventType.Error, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
799 private static void Event(
EventType Type, Exception Exception,
string Object,
string Actor,
string EventId,
800 EventLevel Level,
string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
804 if (Exception is AggregateException ex)
806 foreach (Exception ex2
in ex.InnerExceptions)
807 Event(Type, ex2, Object, Actor, EventId, Level, Facility, Module, Tags);
810 Event(
new Event(Type, Exception, Object, Actor, EventId, Level, Facility, Module, Tags));
820 while (!(Exception?.InnerException is
null))
822 Type T = Exception.GetType();
823 if (Array.IndexOf(nestedExceptionTypes, T) < 0)
825 if (Exception is AggregateException AggregateException &&
826 AggregateException.InnerExceptions.Count == 1)
828 Exception = AggregateException.InnerExceptions[0];
835 Exception = Exception.InnerException;
851 public static void Error(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
852 string Facility, params KeyValuePair<string, object>[] Tags)
854 Event(
EventType.Error, Exception, Object, Actor, EventId, Level, Facility, Tags);
857 private static void Event(
EventType Type, Exception Exception,
string Object,
string Actor,
string EventId,
858 EventLevel Level,
string Facility, params KeyValuePair<string, object>[] Tags)
862 if (Exception is AggregateException ex)
864 foreach (Exception ex2
in ex.InnerExceptions)
865 Event(Type, ex2, Object, Actor, EventId, Level, Facility, Tags);
868 Event(
new Event(Type, Exception, Object, Actor, EventId, Level, Facility, Exception.Source, Tags));
880 public static void Error(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
881 params KeyValuePair<string, object>[] Tags)
883 Event(
EventType.Error, Exception, Object, Actor, EventId, Level, Tags);
886 private static void Event(
EventType Type, Exception Exception,
string Object,
string Actor,
string EventId,
887 EventLevel Level, params KeyValuePair<string, object>[] Tags)
891 if (Exception is AggregateException ex)
893 foreach (Exception ex2
in ex.InnerExceptions)
894 Event(Type, ex2, Object, Actor, EventId, Level, Tags);
897 Event(
new Event(Type, Exception, Object, Actor, EventId, Level,
string.Empty, Exception.Source, Tags));
908 public static void Error(Exception Exception,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
913 private static void Event(
EventType Type, Exception Exception,
string Object,
string Actor,
string EventId,
914 params KeyValuePair<string, object>[] Tags)
918 if (Exception is AggregateException ex)
920 foreach (Exception ex2
in ex.InnerExceptions)
921 Event(Type, ex2, Object, Actor, EventId, Tags);
924 Event(
new Event(Type, Exception, Object, Actor,
string.Empty,
EventLevel.Minor,
string.Empty, Exception.Source, Tags));
934 public static void Error(Exception Exception,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
939 private static void Event(
EventType Type, Exception Exception,
string Object,
string Actor,
940 params KeyValuePair<string, object>[] Tags)
944 if (Exception is AggregateException ex)
946 foreach (Exception ex2
in ex.InnerExceptions)
947 Event(Type, ex2, Object, Actor, Tags);
950 Event(
new Event(Type, Exception, Object, Actor,
string.Empty,
EventLevel.Minor,
string.Empty, Exception.Source, Tags));
959 public static void Error(Exception Exception,
string Object, params KeyValuePair<string, object>[] Tags)
964 private static void Event(
EventType Type, Exception Exception,
string Object,
965 params KeyValuePair<string, object>[] Tags)
969 if (Exception is AggregateException ex)
971 foreach (Exception ex2
in ex.InnerExceptions)
972 Event(Type, ex2, Object, Tags);
975 Event(
new Event(Type, Exception, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty, Exception.Source, Tags));
983 public static void Error(Exception Exception, params KeyValuePair<string, object>[] Tags)
988 private static void Event(
EventType Type, Exception Exception, params KeyValuePair<string, object>[] Tags)
992 if (Exception is AggregateException ex)
994 foreach (Exception ex2
in ex.InnerExceptions)
995 Event(Type, ex2, Tags);
998 Event(
new Event(Type, Exception,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty, Exception.Source, Tags));
1017 public static void Critical(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1018 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
1020 Event(
new Event(
EventType.Critical, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
1034 public static void Critical(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1035 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1037 Event(
new Event(
EventType.Critical, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
1050 public static void Critical(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1051 string Facility, params KeyValuePair<string, object>[] Tags)
1053 Event(
new Event(
EventType.Critical, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
1065 public static void Critical(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1066 params KeyValuePair<string, object>[] Tags)
1068 Event(
new Event(
EventType.Critical, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
1079 public static void Critical(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1091 public static void Critical(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1093 Event(
new Event(
EventType.Critical, Message, Object, Actor,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1102 public static void Critical(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
1104 Event(
new Event(
EventType.Critical, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1112 public static void Critical(
string Message, params KeyValuePair<string, object>[] Tags)
1114 Event(
new Event(
EventType.Critical, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1128 public static void Critical(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1129 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1131 Event(
EventType.Critical, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1144 public static void Critical(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1145 string Facility, params KeyValuePair<string, object>[] Tags)
1147 Event(
EventType.Critical, Exception, Object, Actor, EventId, Level, Facility, Tags);
1159 public static void Critical(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1160 params KeyValuePair<string, object>[] Tags)
1162 Event(
EventType.Critical, Exception, Object, Actor, EventId, Level, Tags);
1173 public static void Critical(Exception Exception,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1175 Event(
EventType.Critical, Exception, Object, Actor, EventId, Tags);
1185 public static void Critical(Exception Exception,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1196 public static void Critical(Exception Exception,
string Object, params KeyValuePair<string, object>[] Tags)
1206 public static void Critical(Exception Exception, params KeyValuePair<string, object>[] Tags)
1227 public static void Alert(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1228 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
1230 Event(
new Event(
EventType.Alert, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
1244 public static void Alert(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1245 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1247 Event(
new Event(
EventType.Alert, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
1260 public static void Alert(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1261 string Facility, params KeyValuePair<string, object>[] Tags)
1263 Event(
new Event(
EventType.Alert, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
1275 public static void Alert(
string Message,
string Object,
string Actor,
string EventId,
EventLevel Level,
1276 params KeyValuePair<string, object>[] Tags)
1278 Event(
new Event(
EventType.Alert, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
1289 public static void Alert(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1301 public static void Alert(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1312 public static void Alert(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
1314 Event(
new Event(
EventType.Alert, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1322 public static void Alert(
string Message, params KeyValuePair<string, object>[] Tags)
1324 Event(
new Event(
EventType.Alert, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1338 public static void Alert(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1339 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1341 Event(
EventType.Alert, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1354 public static void Alert(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1355 string Facility, params KeyValuePair<string, object>[] Tags)
1357 Event(
EventType.Alert, Exception, Object, Actor, EventId, Level, Facility, Tags);
1369 public static void Alert(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1370 params KeyValuePair<string, object>[] Tags)
1372 Event(
EventType.Alert, Exception, Object, Actor, EventId, Level, Tags);
1383 public static void Alert(Exception Exception,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1395 public static void Alert(Exception Exception,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1406 public static void Alert(Exception Exception,
string Object, params KeyValuePair<string, object>[] Tags)
1416 public static void Alert(Exception Exception, params KeyValuePair<string, object>[] Tags)
1438 string Facility,
string Module,
string StackTrace, params KeyValuePair<string, object>[] Tags)
1440 Event(
new Event(
EventType.Emergency, Message, Object, Actor, EventId, Level, Facility, Module, StackTrace, Tags));
1455 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1457 Event(
new Event(
EventType.Emergency, Message, Object, Actor, EventId, Level, Facility, Module,
string.Empty, Tags));
1471 string Facility, params KeyValuePair<string, object>[] Tags)
1473 Event(
new Event(
EventType.Emergency, Message, Object, Actor, EventId, Level, Facility,
string.Empty,
string.Empty, Tags));
1486 params KeyValuePair<string, object>[] Tags)
1488 Event(
new Event(
EventType.Emergency, Message, Object, Actor, EventId, Level,
string.Empty,
string.Empty,
string.Empty, Tags));
1499 public static void Emergency(
string Message,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1511 public static void Emergency(
string Message,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1513 Event(
new Event(
EventType.Emergency, Message, Object, Actor,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1522 public static void Emergency(
string Message,
string Object, params KeyValuePair<string, object>[] Tags)
1524 Event(
new Event(
EventType.Emergency, Message, Object,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1532 public static void Emergency(
string Message, params KeyValuePair<string, object>[] Tags)
1534 Event(
new Event(
EventType.Emergency, Message,
string.Empty,
string.Empty,
string.Empty,
EventLevel.Minor,
string.Empty,
string.Empty,
string.Empty, Tags));
1548 public static void Emergency(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1549 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1551 Event(
EventType.Emergency, Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1564 public static void Emergency(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1565 string Facility, params KeyValuePair<string, object>[] Tags)
1567 Event(
EventType.Emergency, Exception, Object, Actor, EventId, Level, Facility, Tags);
1579 public static void Emergency(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1580 params KeyValuePair<string, object>[] Tags)
1582 Event(
EventType.Emergency, Exception, Object, Actor, EventId, Level, Tags);
1593 public static void Emergency(Exception Exception,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1595 Event(
EventType.Emergency, Exception, Object, Actor, EventId, Tags);
1605 public static void Emergency(Exception Exception,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1616 public static void Emergency(Exception Exception,
string Object, params KeyValuePair<string, object>[] Tags)
1626 public static void Emergency(Exception Exception, params KeyValuePair<string, object>[] Tags)
1647 public static void Exception(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1648 string Facility,
string Module, params KeyValuePair<string, object>[] Tags)
1650 Event(
GetEventType(Exception), Exception, Object, Actor, EventId, Level, Facility, Module, Tags);
1663 public static void Exception(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1664 string Facility, params KeyValuePair<string, object>[] Tags)
1666 Event(
GetEventType(Exception), Exception, Object, Actor, EventId, Level, Facility, Tags);
1678 public static void Exception(Exception Exception,
string Object,
string Actor,
string EventId,
EventLevel Level,
1679 params KeyValuePair<string, object>[] Tags)
1692 public static void Exception(Exception Exception,
string Object,
string Actor,
string EventId, params KeyValuePair<string, object>[] Tags)
1704 public static void Exception(Exception Exception,
string Object,
string Actor, params KeyValuePair<string, object>[] Tags)
1715 public static void Exception(Exception Exception,
string Object, params KeyValuePair<string, object>[] Tags)
1725 public static void Exception(Exception Exception, params KeyValuePair<string, object>[] Tags)
1738 if (Array.IndexOf(alertExceptionTypes, Exception.GetType()) >= 0)
1753 List<Type> NewTypes =
new List<Type>();
1754 bool Changed =
false;
1756 NewTypes.AddRange(alertExceptionTypes);
1758 foreach (Type ExceptionType
in ExceptionTypes)
1760 if (!NewTypes.Contains(ExceptionType))
1762 if (alertExceptionTypesLocked)
1763 throw new InvalidOperationException(
"List of alert exception types has been locked.");
1765 NewTypes.Add(ExceptionType);
1771 alertExceptionTypes = NewTypes.ToArray();
1773 alertExceptionTypesLocked = Lock;
1787 public static T[]
Join<T>(
this T[] Array, params T[] NewElements)
1792 int c = Array.Length;
1796 if (NewElements is
null)
1799 int d = NewElements.Length;
1803 T[] Result =
new T[c + d];
1805 System.Array.Copy(Array, 0, Result, 0, c);
1806 System.Array.Copy(NewElements, 0, Result, c, d);
Class representing an event.
void Avoid(IEventSink EventSink)
If the event sink EventSink should be avoided when logging the event.
bool ShoudAvoid(IEventSink EventSink)
If the event sink EventSink should be avoided when logging the event.
Base class for event sinks.
abstract Task Queue(Event Event)
Queues an event to be output.
Static class managing the application event log. Applications and services log events on this static ...
static void Debug(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Alert(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Alert(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Exception(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Emergency(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Informational(string Message, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Emergency(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Error(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Debug(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Terminate()
Must be called when the application is terminated. Stops all event sinks that have been registered.
static void Critical(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void RegisterAlertExceptionType(bool Lock, params Type[] ExceptionTypes)
Registers a set of Exception types as Exception types that should generate alert log entries when log...
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Error(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static string CleanStackTrace(string StackTrace)
Cleans a Stack Trace string, removing entries from the asynchronous execution model,...
static void Critical(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Emergency(string Message, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Emergency(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static IEventSink[] Sinks
Registered sinks.
static void Alert(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Informational(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Warning(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Warning(string Message, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Error(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static EventHandler Terminating
Event raised when the application is terminating.
static void Alert(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Alert(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Critical(string Message, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Notice(string Message, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static bool RegisterExceptionToUnnest(Type ExceptionType)
Register an exception type to unnest in logging. By default, only the TargetInvocationException is un...
static void Alert(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Emergency(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Emergency(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Notice(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Emergency(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Critical(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Emergency(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Emergency(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Emergency(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Register(IEventSink EventSink)
Registers an event sink with the event log. Call Unregister(IEventSink) to unregister it,...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Notice(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Debug(string Message, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Error(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Exception(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Exception(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Informational(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Error(string Message, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Error(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static T[] Join< T >(this T[] Array, params T[] NewElements)
Joins two arrays
static void Debug(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Error(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Critical(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Warning(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Alert(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Alert(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Exception(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Alert(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Critical(Exception Exception, string Object, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Alert(string Message, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static EventType GetEventType(Exception Exception)
Gets the event type corresponding to a given exception object.
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Critical(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Error(Exception Exception, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Error(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Critical(Exception Exception, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Error(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs an error event.
static void Critical(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static Exception UnnestException(Exception Exception)
Unnests an exception, to extract the relevant inner exception.
static bool Unregister(IEventSink EventSink)
Unregisters an event sink from the event log.
static void Emergency(string Message, string Object, string Actor, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Critical(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Warning(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Critical(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Debug(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a debug event.
static void Critical(Exception Exception, params KeyValuePair< string, object >[] Tags)
Logs a critical event.
static void Warning(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs a warning event.
static void Informational(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
static void Alert(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
static void Alert(string Message, string Object, string Actor, string EventId, params KeyValuePair< string, object >[] Tags)
Logs an alert event.
static void Emergency(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an emergency event.
static async void Event(Event Event)
Logs an event. It will be distributed to registered event sinks.
static void Notice(string Message, string Object, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
static void Error(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an error event.
virtual string ObjectID
Object ID, used when logging events.
Interface for all event sinks.