Catching database trace listener errors

Topics: Logging Application Block
Sep 29, 2009 at 12:18 AM

Hi,

I'm new to the enterprise library, I'm trying to implement a database and email trace listeners to log errors. What I wanted to do is first try to log the error to the database, and if that fails for some reason (maybe error log database server is down) I would like to then try to send the email. In my exception policy my first handler is the logging handler which will use the data base logger to write the error to the database but I would like to be able to re-throw an exception from that handler if the logger fails. When I set the posthandlingaction to either rethrow or throw new the original exception always gets re-thrown and not a logger failing exception even if the database logger fails, ( so I force the logger to fail by turning off server or taking away user permissions)

I'm not sure if I should be writing a custom database trace listener which will throw back an error? I can't seem to get a trace listener to return errors.

Thanks a lot

 

Chris

Sep 29, 2009 at 7:32 AM

Hi,

Try adding a Email Trace Listener reference in the Special Sources > Logging Errors & Warnings of the logging application block. In this way, if there will be an error in the process of logging to the database, the email trace listener will catch the failure.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Sep 29, 2009 at 9:13 PM

Hi,

Thanks for the quick reply, I tried playing with the Special Sources -> Logging Errors and Warnings and even implemented my own custom database trace listener but I still can not catch an error generated by the logging handler. In the simplest case scenario what I would like is a Global Unhandled Exception Policy which writes some unhandled error to a shared database.  In the global unhandled Policy I have a single exception type, "Global_Unhandled_Policy_Exception" that exception type has only a single logging handler which I want to use to write to a common shared errors database.

However in the event that my database logger may fail I would like to try to send out an email, so if the common errors database server is down I would like the Database logging handler to generate an error catch a database logging handler error and invoke an exception logger policy to try to email the original error.

I have no issues if in the policy I will try to send out both errors at once so whether or not the database logger fails I get the email but I only want an email if the database logger fails.

Would you mind pointing me to an example of using the Special Sources -> logging errors and Warnings to catch logger generated errors, I tried looking for those but just could not find anything

 

Thanks again,

 

Chris

Sep 30, 2009 at 3:45 AM

Hi,

I could send a sample solution, where can I send it?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Sep 30, 2009 at 5:06 AM

Hi,

My email is derkowski@gmail.com,

Thanks so much,

Chris