protected override void WriteException(IExceptionEntry eventEntry) { var translator = GetTranslator(); var data = translator.TranslateException(eventEntry); WriteToEventViewer(GetSource(), data, EventLogEntryType.Error); }
protected override void WriteException(IExceptionEntry eventEntry) { var translator = GetTranslator(); var data = translator.TranslateException(eventEntry); WriteToFile(data); }
protected override void WriteException(IExceptionEntry eventEntry) { if (eventEntry != null) { if (eventEntry.Id == Guid.Empty) { eventEntry.Id = Guid.NewGuid(); } var str = Newtonsoft.Json.JsonConvert.SerializeObject(eventEntry); PushData(str); } }
/// <summary> /// Default implementation, returns the object "as is", this method should be overridden in /// case of any customizations required e.g. masking capability addition. /// Also think of overriding <seealso cref="FormatTransaction"/> /// </summary> /// <param name="exceptionEntry">The exception entry to be formatted.</param> /// <returns>Formatted exception.</returns> public virtual IExceptionEntry FormatException(IExceptionEntry exceptionEntry) { return(exceptionEntry); }
/// <summary> /// Formats and translates the exception into an <see cref="IExceptionEntry"/> object. /// </summary> /// <param name="exception">The exception to format.</param> /// <param name="entry">The <see cref="IExceptionEntry"/> object to format.</param> /// <returns>The entry object provided with excpetion information added.</returns> protected internal virtual IExceptionEntry FormatException(Exception exception, IExceptionEntry entry) { if (exception.InnerException != null) { entry.AddInnerExceptionMessage(exception.InnerException.ToString()); var builder = new StringBuilder(); var innerException = exception.InnerException; builder.AppendLine("----Flattened Exception Data[BEGIN]----"); while (innerException != null) { foreach (var pair in innerException.Data.Cast <DictionaryEntry>()) { builder.Append(pair.Key).Append(":").Append(pair.Value).AppendLine("---"); } innerException = innerException.InnerException; } builder.AppendLine("----Flattened Exception Data[END]----"); entry.AddInnerExceptionMessage(builder.ToString()); } entry.AddMessage(exception.Message); entry.Source = exception.Source; entry.Type = exception.GetType().Name; entry.StackTrace = exception.StackTrace; entry.TargetSite = exception.TargetSite == null ? string.Empty : exception.TargetSite.Name; if (exception.Data.Count > 0) { entry.AddMessage("---Main Exception Data---"); try { foreach (var pair in exception.Data.Cast <DictionaryEntry>()) { entry.AddMessage(pair.Key + ": " + pair.Value); } } catch { } } return(entry); }
public string TranslateException(IExceptionEntry entry) { return(DumpObject(entry)); }
protected override void WriteException(IExceptionEntry eventEntry) { System.Threading.Thread.Sleep(500); }
protected abstract void WriteException(IExceptionEntry eventEntry);
protected override IExceptionEntry FormatException(Exception exception, IExceptionEntry entry) { return(base.FormatException(exception, entry)); }
public override IExceptionEntry FormatException(IExceptionEntry exceptionEntry) { exceptionEntry.AddMessage("This extensibility point is really useful!"); return(base.FormatException(exceptionEntry)); }
protected override void WriteException(IExceptionEntry eventEntry) { throw new Exception("I have failed event log.", new Exception("This is a test.", new Exception("inner most exception message"))); }