ELMAH Integration in ASP.NET MVC Application - Blogs

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 asp.net 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.



Token Based Authentication for Web API's

Securing ASP.NET Web API using Custom Token Based AuthenticationProviding a security to the Web API&...

Read More >

ASP.NET: Audit Trail Implementation using Entity Framework

When you are working with certain projects which involves the Customer records, you might need to tr...

Read More >

Asynchronous actions in MVC 5

What does it mean?Asynchronous actions allow developers to handle more concurrent requests and can b...

Read More >

Unit testing in .NET

Unit Testing – ExplainedA process which involves writing code to verify a system at a lower an...

Read More >


View Engine is responsible for rendering the view into html form to the browser.ASP.NET MVC includes...

Read More >

ViewData and ViewBag in MVC

ASP.NET MVC provides us two options ViewData and ViewBag for passing data from controller to view.Vi...

Read More >

Creating a Simple Form with Validation Using ASP.NET MVC 4 Empty Template

There are multiple Validation attributes available in MVC. Validation attributes comes from System.C...

Read More >

Brief Journey to Asp.Net MVC Framework

Introduction: ASP.NET MVC is a  framework for building web applications that uses the mode...

Read More >


Try DevOpSmartBoard Ultimate complete Azure DevOps End-to end reporting tool

Sign Up

  • Recent
  • Popular
  • Tag
Monthly Archive

Contact Us
  • *
  • *