Elmah
By eidias on (tags: logging, categories: infrastructure)Elmah stands for Error Logging Modules and Handlers. It’s a very interesting little library. There’s a pretty neat (although old) article on it by Scott Hanselman and a follow up.
The usage is very simple, especially combined with nuget – just type in
1: Install-Package elmah
1: Install-Package elmah.sqlservercompact
But what does it store? Well, elmah catches all errors and keeps them in one place. By default it keeps them in memory, but you can configure this to be pretty much anything – from SQL Server Express, through SQL Server CE 4.0 to xml and if you don’t find a suitable storage – you can always write your own error log by extending the ErrorLog class.
The nice thing about it is that you just install the package, and that’s it. There’s a viewer available under /elmah.axd where you can view the caught errors.
Now this does not seem like something much during development, but in a production environment, I’d say that it can be really useful. It will give you the overall health status of your web app (I probably should have mentioned this before – it’s for asp.net web applications only)
In order to make it work smoothly with asp.net mvc, a little code is required. It’s explained here.
Cheers