private void ReportMissingCategories(List <string> missingCategories, LogEntry logEntry) { try { LogEntry reportingLogEntry = new LogEntry(); reportingLogEntry.Severity = TraceEventType.Error; reportingLogEntry.Message = string.Format(Resources.Culture, Resources.MissingCategories, TextFormatter.FormatCategoriesCollection(missingCategories), logEntry.ToString()); reportingLogEntry.EventId = LogWriterFailureEventID; structureHolder.ErrorsTraceSource.TraceData(reportingLogEntry.Severity, reportingLogEntry.EventId, reportingLogEntry); } catch (Exception ex) { instrumentationProvider.FireFailureLoggingErrorEvent(Resources.FailureWhileReportingMissingCategories, ex); } }
private void logEventInformationButton_Click(object sender, EventArgs e) { EventInformationForm eventForm = new EventInformationForm(); DialogResult result = eventForm.ShowDialog(); if (result == DialogResult.OK) { try { Cursor.Current = Cursors.WaitCursor; // Creates and fills the log entry with user information LogEntry logEntry = new LogEntry(); logEntry.EventId = eventForm.EventId; logEntry.Priority = eventForm.Priority; logEntry.Message = eventForm.Message; logEntry.Categories.Clear(); // Add the categories selected by the user foreach (string category in eventForm.Categories) { logEntry.Categories.Add(category); } DisplayScenarioStart(String.Format(Properties.Resources.LogEventStartMessage, logEntry.ToString())); // Writes the log entry. Logger.Write(logEntry); this.DisplayResults(String.Format(Properties.Resources.EventProcessedMessage, logEntry.EventId)); } catch (Exception ex) { ProcessUnhandledException(ex); } finally { Cursor.Current = Cursors.Default; } } }
private void ReportUnknownException(Exception exception, LogEntry log) { try { NameValueCollection additionalInfo = new NameValueCollection(); additionalInfo.Add(ExceptionFormatter.Header, Resources.ProcessMessageFailed); additionalInfo.Add(Resources.ProcessMessageFailed2, string.Format(Resources.Culture, Resources.ProcessMessageFailed3, log.ToString())); ExceptionFormatter formatter = new ExceptionFormatter(additionalInfo, Resources.DistributorEventLoggerDefaultApplicationName); LogEntry reportingLogEntry = new LogEntry(); reportingLogEntry.Severity = TraceEventType.Error; reportingLogEntry.Message = formatter.GetMessage(exception); reportingLogEntry.EventId = LogWriterFailureEventID; structureHolder.ErrorsTraceSource.TraceData(reportingLogEntry.Severity, reportingLogEntry.EventId, reportingLogEntry); } catch (Exception ex) { instrumentationProvider.FireFailureLoggingErrorEvent(Resources.UnknownFailure, ex); } }