Canarys | IT Services


ELMAH Integration in ASP.NET MVC Application



(Error Logging Modules And Handlers)

What is ELMAH?

ELMAH (Error Logging Modules and Handlers) is a series of HTTP modules and an HTTP handler that may be added to your ASP.NET web applications for the purpose of tracking unhandled exceptions. ELMAH provides access to view these errors by way of a web console, email notifications. It is open-source error logging system. ELAMH displays a list of errors and the details of a specific error from a web page.

Exception log Files Storage: 

ELMAH error logs can be saved in relational databases, in-memory store and XML files.

Referencing ELMAH to an ASP.NET Application

ELMAH can be integrated into the application in two ways.

·         NuGet (By adding the Elmah.MVC NuGet Package).

·         Dll (Elmah dll).

Installing using the NuGet

  •   ELMAH is basically a NuGet package for .NET web applications, logging every exception occurring on websites
  •   To install Elmah.MVC run the following command in the “Package Manager Console” which is available under “tools >> library package manager >> package manager console” as shown in the below screen shot.


  •   Run the Command      PM> Install-Package Elmah.MVC

Referencing ELMAH assemblies


  • If you get the compiled assemblies, just make a reference to Elmah.dll. If you get the source, you will need to build it and then reference it in your project solution.

Adding ELMAH in Web.config file


Sections to be added in your Web.config and make these changes:

  •  Add this “configSections” within “configuration”
  • Add this “elmah” section within “configuration”

               Add under the “configSections”.

              There are two ways the log the errors:

       i.   Relational databases

       ii.   XML files.

I.   Relational databases

This will enable ELMAH to save the error log to the database using

“MyElmahConnectionString” connection string.

Note: Database Tables and stored procedures has to be executed before logging the Exceptions into the Relational Database.

  II.   XML Files

This will enable ELMAH to save the error log into XML files on a local disk.

  •   Add this “Http Handlers”, “Http Modules” section in “System.web” within “configuration”
  • Add this “Handlers”, “Modules” section in “System.webServer”

              Within “configuration”

The integration of the ELMAH into the web application is done.

Viewing the ELMAH Logged Errors:

Now, when you navigate to /elmah.axd you’ll be able to see ELMAH’s interface with the logged errors as shown in the below screen shot.


  •   It is easy and we can add dynamically without any re-deployment and re-compilation.
  •   We can view all the error logs through an authenticated page in the applications.
  •   It is easy tool for debugging the unhandled exceptions in the application.

Leave a Reply

Your email address will not be published. Required fields are marked *

Reach Us

With Canarys,
Let’s Plan. Grow. Strive. Succeed.