/// <summary> /// Method used to write exception and additional information to the event log, and clears the /// messages collection. /// </summary> /// <param name="exception">The exception object whose information should be written to log file.</param> /// <param name="severity">The type of event log entry (warning, information, error,...)</param> public void WriteToLog(Exception exception, Severity severity) { // Verify that the specified event log exists and is valid to write to. CheckEventLog(); string finalMessage = String.Empty; finalMessage = GetMessage(exception); additionalInfo.Clear(); if (severity == Severity.Error || severity == Severity.Warning) { // this only fires WMI events LoggingServiceFailureEvent.Fire(finalMessage, exception); } EventLog.WriteEntry(this.ApplicationName, finalMessage, SeverityMap.GetEventLogEntryType(severity)); }
private void FireLoggingServiceFailureEvent() { LoggingServiceFailureEvent.Fire(testMessage, new Exception("TEST")); }