tags:

views:

278

answers:

2

I can wire up Elmah to log Exceptions in my ASP.Net application and it works well.

I also have a requirement to audit interesting events that occur in the application. For example, I must audit the "email address was changed" event and store the old and new email address.

Is it appropriate to use Elmah to log these interesting events? It doesn't seem like Elmah is configured to log anything beyond exceptions.

I could smush it in there and create a fake Exception, but that smells funny. On the other hand, it seems bad to have multiple log repositories laying around for a small application.

Is it appropriate to use Elmah as an audit repository and create fake exceptions? Can Elmah store "info" items, in addition to exceptions? Is there a better repository for interesting events when I'm already using Elmah?

A: 

Definitely don't use ELMAH for auditing. Either build auditing into your business logic or at the very least use something like log4net to log it somewhere else.

John Sheehan
Well, Elmah can be used for custom logging also - like: Elmah.ErrorLog.GetDefault(Context).Log(new Elmah.Error(new Exception("Sample Text")));
NinethSense
Yep, Nineth, that's what I do for simple/quick apps.
Will
John, can you provide a few reasons to support your view? EMAB, Log4Net, ASP.Net Health Monitoring and others can log errors; perhaps not as well as Elmah, but they do allow for an audit log. Why should exceptions be directed to Elmah, while another layer is used for info audits?
AndrewDotHay
Use log4net or just log the "interesting" event.
rball
It will be a lot more difficult to do anything with the logged data mixed in with all the errors. How are you going to associate it with a user? An account? If you want to pull up a list of all the interesting changes a user made, have fun parsing that out of ELMAH. You could do it, but why would you want to?
John Sheehan
A: 

I think i'd probably create a sql trigger on the fields you are wanting to audit, you wont have mess about with any other applications then, SQL server will just take care of it all for you

beakersoft