title: Lightweight use of Enterprise Library TraceListeners
body: <p>Is it possible to use the Enterprise Library 4.1 TraceListeners without using the entire Enterprise Library Logging AB? I'd prefer to simply use .NET Diagnostics Tracing, but would like to setup a listener that sends emails on Error events. I figured I could use the Enterprise Library EmailTraceListener. However, my initial attempts to configure it have failed. Here's what I hoped would work:</p>
  
  <pre><code>&lt;system.diagnostics&gt;
    &lt;trace autoflush="false" /&gt;
    &lt;sources&gt;
      &lt;source name="SampleSource" switchValue="Verbose" &gt;
        &lt;listeners&gt;
          &lt;add name="textFileListener" /&gt;
          &lt;add name="emailListener" /&gt;
        &lt;/listeners&gt;
      &lt;/source&gt;
    &lt;/sources&gt;
    &lt;sharedListeners&gt;
      &lt;add name="textFileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="..\trace.log" traceOutputOptions="DateTime"&gt;
        &lt;filter type="System.Diagnostics.EventTypeFilter" initializeData="Verbose" /&gt;
      &lt;/add&gt;
      &lt;add name="emailListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging" toAddress="to@example.com" fromAddress="from@example.com" smtpServer="mail.example.com" &gt;
        &lt;filter type="System.Diagnostics.EventTypeFilter" initializeData="Verbose" /&gt;
      &lt;/add&gt;
    &lt;/sharedListeners&gt;
  &lt;/system.diagnostics&gt;
  </code></pre>
  
  <p>However I get </p>
  
  <pre><code>[ArgumentException: The parameter 'address' cannot be an empty string.
  Parameter name: address]
     System.Net.Mail.MailAddress..ctor(String address, String displayName, Encoding displayNameEncoding) +1098157
     System.Net.Mail.MailAddress..ctor(String address) +8
     Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailMessage.CreateMailMessage() +256
     Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.EmailMessage.Send() +39
     Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener.Write(String message) +96
     System.Diagnostics.TraceListener.WriteHeader(String source, TraceEventType eventType, Int32 id) +184
     System.Diagnostics.TraceListener.TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, String format, Object[] args) +63
     System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String format, Object[] args) +198
     System.Diagnostics.TraceSource.TraceInformation(String message) +14
  </code></pre>
  
  <p>Which leads me to believe the .NET Tracing code does not care about the "non-standard" config attributes I've supplied for emailListener.  I also tried adding the appropriate LAB configSection declaration and:</p>
  
  <pre><code>&lt;loggingConfiguration&gt;
    &lt;listeners&gt;
      &lt;add toAddress="to@example.com" fromAddress="from@example.com" smtpServer="mail.example.com" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging" name="emailListener" /&gt;
    &lt;/listeners&gt;
  &lt;/loggingConfiguration&gt;
  </code></pre>
  
  <p>This also results in the same exception. I figure it's possible to programmatically configure the EmailTraceListener, but I prefer this to be config-driven. I also understand I can implement my own derivative of TraceListener.</p>
  
  <p>So, is it possible to use the Ent Lib TraceListeners, without using the whole Ent Lib LAB, and configure them from the config file?</p>
  
  <p><strong>Update</strong>: After examining the code, I have discovered it is not possible. The Ent Lib TraceListeners do not actually utilize the config attributes they specify in overriding TraceListener.GetSupportedAttributes(), despite the recommendations in the .NET TraceListener documentation. Bug filed.</p>