Exception Logging to Email Sink

Send an email when an exception is thrown using EntLib is not rocket science.

Here is a screen shot of how the configuration looks like


The steps involved are:

  1. Create an Exception Handling App Block
  2. Create a New Policy (for instance “Email Policy“)
  3. Create a new type of Exception to manage on the policy. Using “Exception“ will catch every kind of exception thrown
  4. Create a new Logging Handler for the Exception. Here the Logging and Instrumentation App Block will be added to the config.
  5. Add the Email Sink on the Logging Block and configure it (from and to email address, etc).
  6. Create a new Category (for instance “Several“) and add a new Destination
  7. Configure the Destintation to use the Text Formatter and the Email Sink
  8. Go to the Logging Handler node and set the LogCategory to “Several“

Here are the config files ExceptionLoggingToEmail.zip (2.91 KB)

Btw, sending an email is a task that requires some resources so
maybe It would be better to use the Async Logging as I described in the
last post. And let the distributor service to send the exception email in another process or server.

Published: March 31 2005

blog comments powered by Disqus