Why You Should Learn and Love ELMAH
To quote directly from Scott Hanselman:
ELMAH is one of those largely unknown and deeply awesome .NET Open Source projects that should be part of ASP.NET proper.
If you’re working on a web development project; either professionally or privately at home, you need to be aware of ELMAH and what it can provide.
Over the next few posts, I’m going to look at aspects of ELMaH: what it is, what it does, how you can leverage it and what it means for you and your clients.
A Cordial Introduction
ELMAH is an exception logging framework that presents any and all errors encountered by your web application in a format of your choosing. It probably doesn’t sound like much when you read that, but stop and think about it for a minute. With any web application you build, rather than be guessing at 404 pages, trawling through a YSOD‘s stack trace or scrolling through countless lines of Event Log entries, you can view specific exceptions as an XML file, in an email, as an RSS feed, in a database or any combination of these (and more!).
It’s one of those things that, like Grid Layouts or the new Noodle Canteen down the road, have been around for a while and you might have heard about, but it isn’t until you actually have a go at using it that you exclaim “Why the hell didn’t I try this earlier?!”. So let’s have a closer look at it now so that you can really see what it does and how it differs from your garden-variety error trapping.
ELMaH provides a way to wrap exceptions (handled or otherwise) up in a usable and more readable form. You can then retrieve that data in a variety of different ways: in a database, email, or text-based form (XML, RSS or plain text). It allows you to get more granular information about your application’s performance and the errors generated within it. The natural implication here is that it allows you to respond immediately to your customer base – often before they are even aware that a fault exists. You’re providing one more layer of Quality Assurance.
Better Application Development
Scott Hanselman’s post deals with how to implement ELMaH on your MVC site pretty thoroughly, so if you just can’t wait, have a look at it now. What isn’t always so obvious is why you should use it in the first place. The short answer is “customer satisfaction”.
Having clarity around your application’s bugs means that you can identify the cause and address them straight away, often before the user is even aware there is a problem. Your users will have more confidence that your software is robust and, where errors are identified, your support systems are sound. You are able to crash responsibly, to coin a term from Jeff Atwood. You’re no longer relying on your users to tell you where your problem points are in your software.
In fact, Jeff has already posted about this concept and IMHO wiser words were never spoken.
In my next post, I’m going to (very) quickly go through setting up a basic ASP.Net website (I won’t use MVC as this has already been covered in a number of places and there are plenty of people still using web forms projects) and creating a SQL Server database to store the captured information. I’ll then go through creating a really basic application that allows you to securely log in and view that information in meaningful ways, applying some of the good suggestions from Jeff Atwood’s blog, above.
I’ll continue to post resources and links from this post as I arrive at them or as they become available (presentations, downloads, blog posts, etc).


You need to go wash your mouth out for using “.NET” and “Open Source” in the same sentence. Open source is about freedom, pretty much the opposite of .Net.
Ha. Well, technically it wasn’t me that said that. But the code for ELMaH is freely available for anyone to play with.