コード例 #1
0
ファイル: WindowsEventLog.cs プロジェクト: z77ma/runtime
 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)
         {
         }
     }
 }
コード例 #2
0
 public void WriteEntry(string message, EventLogEntryType type, int eventID, short category)
 {
     DiagnosticsEventLog.WriteEvent(new EventInstance(eventID, category, type), message);
 }
コード例 #3
0
ファイル: WindowsEventLog.cs プロジェクト: yxlbyc/Logging
 public void WriteEntry(string message, EventLogEntryType type, int eventID, short category)
 {
     DiagnosticsEventLog.WriteEntry(message, type, eventID, category);
 }