Ukadc.Diagnostics.Listeners.SmtpTraceListener
Description
An implementation of a
CustomTraceListener that sends e-mail via a configured SMTP server with a formatted body and subject thanks to a
CombinedToken.
Example Usage
The first step is to add the SmtpTraceLsietner to your configured listeners
<source name="myTraceSource" switchValue="All">
<listeners>
<add type="Ukadc.Diagnostics.Listeners.SmtpTraceListener, Ukadc.Diagnostics"
name="odsTraceListener" initializeData="mySmtpSettings" />
</listeners>
</source>
The initializeData attribute refers to a seperate piece of configuration stored in the smtpTraceListeners part of the ukadc.Diagnostics section.
<configSections>
<section name="ukadc.diagnostics" type="Ukadc.Diagnostics.Configuration.UkadcDiagnosticsSection, Ukadc.Diagnostics"/>
</configSections>
<ukadc.diagnostics>
<smtpTraceListeners>
<smtpTraceListener name="smtpTraceListenerSettings" host="yourSmtpServer" port="25" from="from@address.com" to="to@address.com"
subject="Logging Event: {EventType}, {MachineName}"
body="{Message}
=======
Process={ProcessId},
Thread={ThreadId},
ActivityId={ActivityId}" />
</smtpTraceListeners>
</ukadc.diagnostics>
IMPORTANT It is strongly recommended that you use a Filter with the SmtpTraceListener to reduce the amount of e-mails to only those of a Critical or Error nature. See the
QuickReferenceExample for a sample showing how to do this.