Alex Rivera | Logout

How to log all error in DB but email errors only on conditional basis?

Asked 2012-02-28T07:35:45.473
9

I want email to be sent only on a specific condition and log error in DB in all cases. But as I understand, filtering can't work for one of the two. Is that right? If so then how can I achieve it?

Also to note that, right now I'm saving additional info to database on ErrorMail_Mailing in global.asax as replied by Atif Aziz. Because email will be sent only on conditional basis and ErrorMail_Mailing fires only while sending email, I wonder how would I be able to save additional info of all errors to database.

UPDATE:
I have modified Elmah code a bit to satisfy my need.

Edit
Report

1 Answer

0

You should try out the StackExchange.Exceptional

This project was inspired by ELMAH, but it didn't suit our particular needs for very, very high volume error logging when a network-level event occurs.

StackExchange.Exceptional is the error handler used internally by Stack Exchange and Stack Overflow for logging to SQL.

It also supports JSON and memory error stores, filtering of exceptions before logging, and fail/retry mechanisms for storing errors if there's an interruption in connecting to the error store.

It's highly customizable and it's really easy to add something according your needs. As i can see an pull request has the email functionality implemented Email functionality so you can start from there.

To set it up you only need to look at the web.config and pick what to enable.

Hope it helps.

answered 2012-11-09T13:13:10.583

Your Answer