Exemple #1
0
 public void WriteEntry(string message, EventLogEntryType type, int eventID, short category)
 {
     try
     {
         if (_enabled)
         {
             DiagnosticsEventLog.WriteEvent(new EventInstance(eventID, category, type), message);
         }
     }
     catch (SecurityException sx)
     {
         _enabled = false;
         // We couldn't create the log or source name. Disable logging.
         try
         {
             using (var backupLog = new System.Diagnostics.EventLog("Application", ".", "Application"))
             {
                 backupLog.WriteEvent(new EventInstance(instanceId: 0, categoryId: 0, EventLogEntryType.Error),
                                      $"Unable to log .NET application events. {sx.Message}");
             }
         }
         catch (Exception)
         {
         }
     }
 }
Exemple #2
0
 public void WriteEntry(string message, EventLogEntryType type, int eventID, short category)
 {
     DiagnosticsEventLog.WriteEvent(new EventInstance(eventID, category, type), message);
 }
Exemple #3
0
 public void WriteEntry(string message, EventLogEntryType type, int eventID, short category)
 {
     DiagnosticsEventLog.WriteEntry(message, type, eventID, category);
 }