Site icon Dotnet Helpers

Logging Errors using ELMAH In ASP.NET MVC- Part I

What is ELMAH?

ELMAH provide way for logging Error at runtime in a Local/Production environment.  ELMAH is a open source error logging library/dll that includes features like error filtering and able to  view the error logs by a web page (localhost:50287/elmah.axd). It would very difficult to track/debug the error after code has been moved to production environment. To avoid this type of difficulties we are using ELMAH for logging.

Note : The main purpose of ELMAH it to log all the unhandled exceptions in our application.

Implementing ELMAH in our Application :

STEP 1: Installing ELMAH

Install ELMAH using NuGet, go to Tools -> Library Package Manager -> Package Manager console and type “Install-Package elmah” as shown in below.

STEP 2:

After successfull installation, elmah will add required library in our application and update the web.config file. Verify whether below changes has been updated in the webconfig after the successfull installation.

STEP 3: 

Run the application and try to access contoller/action which is not present in our application for tracking the error.
After that include elmah.axd at the end of the url to show the errors which has been caught from starting as shown below.

NOTE : If you not able to access the elmah.axd page then include the below line in Global.asax

RouteTable.Routes.Ignore(“{resource}.axd/{*pathInfo}”);

We will discuss more about ELMAH in upcoming posts.

Keep cool coding…

 

Exit mobile version