/// <summary> /// Adds the trace info as extended data to the error. /// </summary> /// <param name="error">The error model.</param> public static void AddRecentTraceLogEntries(this Error error) { if (error.ExtendedData.ContainsKey(ExtendedDataDictionary.TRACE_LOG_KEY)) { return; } ExceptionlessTraceListener traceListener = Trace.Listeners .OfType <ExceptionlessTraceListener>() .FirstOrDefault(); if (traceListener == null) { return; } List <string> logEntries = traceListener.GetLogEntries(); if (logEntries.Count > 0) { error.ExtendedData.Add(ExtendedDataDictionary.TRACE_LOG_KEY, traceListener.GetLogEntries()); } }
/// <summary> /// Adds the trace info as extended data to the event. /// </summary> /// <param name="ev">The event model.</param> /// <param name="listener">The listener.</param> /// <param name="maxEntriesToInclude"></param> public static void AddRecentTraceLogEntries(Event ev, ExceptionlessTraceListener listener = null, int maxEntriesToInclude = DefaultMaxEntriesToInclude) { if (ev.Data.ContainsKey(Event.KnownDataKeys.TraceLog)) { return; } listener = listener ?? Trace.Listeners.OfType <ExceptionlessTraceListener>().FirstOrDefault(); if (listener == null) { return; } List <string> logEntries = listener.GetLogEntries(maxEntriesToInclude); if (logEntries.Count > 0) { ev.Data.Add(Event.KnownDataKeys.TraceLog, logEntries); } }