Skip to content

Instantly share code, notes, and snippets.

@niemyjski
Created December 16, 2014 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niemyjski/469ccce03dc5b753d522 to your computer and use it in GitHub Desktop.
Save niemyjski/469ccce03dc5b753d522 to your computer and use it in GitHub Desktop.
Exceptionless Log Source Trace Messages
internal static readonly TraceSource _traceSource = new TraceSource("MyLogSource");
ExceptionlessTraceListener traceListener = Trace.Listeners.OfType<ExceptionlessTraceListener>().FirstOrDefault();
if (traceListener != null)
_traceSource.Listeners.Add(traceListener);
OR
<system.diagnostics>
<sharedListeners>
<add name="DiskLog" type="System.Diagnostics.TextWriterTraceListener" traceOutputOptions="DateTime" initializeData="MyLog.log" />
<add name="Exceptionless" type="Exceptionless.Diagnostics.ExceptionlessTraceListener, Exceptionless" traceOutputOptions="DateTime" initializeData="25" />
</sharedListeners>
<sources>
<source name="MyLogSource" switchValue="All">
<listeners>
<add name="DiskLog"/>
<add name="Exceptionless"/>
</listeners>
</source>
</sources>
<trace autoflush="true" useGlobalLock="true">
<listeners>
<add name="Exceptionless" />
</listeners>
</trace>
</system.diagnostics>
OR (Include just your log source)
Wireup to the exceptionless sending event. Grab the Listener from your trace source and attach it as extended data.
<system.diagnostics>
<sharedListeners>
<add name="DiskLog" type="System.Diagnostics.TextWriterTraceListener" traceOutputOptions="DateTime" initializeData="MyLog.log" />
<add name="Exceptionless" type="Exceptionless.Diagnostics.ExceptionlessTraceListener, Exceptionless" traceOutputOptions="DateTime" initializeData="25" />
</sharedListeners>
<sources>
<source name="MyLogSource" switchValue="All">
<listeners>
<add name="DiskLog"/>
<add name="Exceptionless"/>
</listeners>
</source>
</sources>
</system.diagnostics>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment