Logging Application Block question

Topics: Logging Application Block
Oct 28, 2009 at 4:48 PM

Does the logging application block provide functionality to handle Exceptions based upon Exception type and Exception property values?   For example:

If my code encouters a SQLException with a specified error code or exception message then send an email.

In my case it would be handy to conditionally notify (via email) when a sql timeout or sql dead lock ocurrs.  Unfortunately, the microsoft sql errors aren't subdivided into different exception types (hence the desire to handle them differently based upon their property values).




Oct 29, 2009 at 6:09 AM


I think that can be done by the Exception Handling Application Block (http://msdn.microsoft.com/en-us/library/dd203116.aspx) together with the Logging Application Block, In the Exception Handling Block, you can specify a exception type to handle the add a logging handler(which will do the logging part). Now, You want it also to be based to the exception property value, so instead of adding a logging handler, you will now create your own exception handler, then in your handler, implement your logic for checking your exception property values and logging.

Creating Custom Exception Handler: http://msdn.microsoft.com/en-us/library/dd140058.aspx

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.