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>


emailError.png

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.

Last edited Apr 11, 2008 at 11:48 AM by joshtwist, version 4

Comments

No comments yet.