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) { } } }
public void WriteEntry(string message, EventLogEntryType type, int eventID, short category) { DiagnosticsEventLog.WriteEvent(new EventInstance(eventID, category, type), message); }
public void WriteEntry(string message, EventLogEntryType type, int eventID, short category) { DiagnosticsEventLog.WriteEntry(message, type, eventID, category); }