views:

360

answers:

1

Hi everyone.

I've got a ASP.NET website that is utilizing many aspects of the Enterprise Library (3.1), including the Logging Application Block. I'm using a custom TraceListener to handle all of the logging requests.

I want to add an email listener that will fire an email whenever an error occurs in the website. To be clear (and because I made the same mistake), this cannot be achieved by adding the following to your config file:

  <errors switchValue="All" name="Logging Errors &amp; Warnings">
    <listeners>
      <add name="Email Listener" />
    </listeners>

This will send an email whenever an error occurs in logging, not when Trace.TraceError() is called. I've found a few examples of writing custom code to do this, but that's not what I want to do.

I'm sure that this was thought about when Enterprise Library was developed, and I'm hoping to run into one of the bright souls answering questions on Stack Overflow who has run into this. Thanks in advance!

UPDATE

Solved. Ended up using a category and firing an email on that.

<categorySources>
  <add switchValue="Error" name="Errors">
    <listeners>
      <add name="Email Listener" />
    </listeners>
  </add>
</categorySources>
A: 

Couldn't you do something like (pseudocode)

<allEvents switchValue="Error" name="blahblah">
  <listeners><add name="Email Listener"/></listeners>

?

Joe