ELMAH stands for Error Logging Modules and Handlers and if you have an ASP.NET web application or web site and you want a very easy way to use it then this article is for you.

Note I am going to use NuGet to add ELMAH to an existing application using Visual Studio 2010.

For this tutorial I am going to sue the NuGet Package Console instead of using the other option which is ‘Add Library Package Reference’, let’s get started:-

1 – Open an existing VS2010 web application and then select ‘Tools’, ‘Library Package Manager’ and then select ‘Package Manage Console’.
2 – One you have the console window check to make sure your Package Source is pointing to the NuGet Official package source and the type:-

List-Package -remote

and then press enter

3 – This will list all available packages which you can add to your application – Note if you have several projects within your solution make sure you have the project you want to add ELMAH to selected in the console right hand drop down, below I am looking at the official packages and adding to my MVC site as you can see:-

Package Manager Console

4 – Ok now type:-

Install-package ELMAH

and then press enter

check now and you will see that ELMAH has indeed been added and your web.config has changed with all the settings for ELMAH having been added to your file – Uninstall-package ELMAH would undo this work.

5 – Thats it, ELMAH has been added to your project. To test it working and as an example add a testpage and just throw an exception on it, or browse to a page that doesnt exist within your app and then in your web browser url browse to /elmah.axd – Note this is logging into the app code folder and writing to .xml files – part 2 of this blog post will discuss logging using SQL instead of using this method.

6 – Voila ELMAH is logging all your app errors.