In this article you will learn about the ELMAH tool for debugging mainly ASP.NET applications.
IntroductionError Logging Modules & Handlers (ELMAH) is a tool for debugging mainly ASP.NET applications as suggested by the wiki. Since we all know there is always a chance of getting exceptions when working on any applications. Handling them is a real challenge for many developers. But if we have a tool then it can provide the details of the exceptions or errors with the stack trace as well. Apart from showing the users the Yellow screen of death, we show the users a customized error page and for the developers if an exception occurs then instead of a try/catch block for every method, ELMAH provides them the details of the exceptions with the entire stack trace and a solution based on the error code. For more information on error codes and redirection please follow one of my other articles Custom Errors. Let's get into more details of how this beautiful tool works. What we getYou would be wondering what this ELMAH gives us after adding this into the application. Straight from the Hanselmen's blog, ELMAH would provide us the following without changing a single peice of code. Since ELMAH includes modules and handlers, it greatly supports HttpModules and Http Handlers.
Suppose the preceding is the case and the user using the application lands on the preceding redirect path URL pages, whereas the error and exception are managed by ELMAH and mailed or logged into the database for future reference for the developers. Installation for an existing MVC projectStep 1
Go to references and right-click on the Manage Nuget Packages.Step 2
Search online for Elmah.MVC.Step 3
After the successful installation, you can check the package.config for the version of ELMAH installed as shown below:Step 4
You need to ensure the following web.config configurations as shown in the images below:
Thus, we have discussed everything related to ELMAH. In the future article/blog I will be explaining how to store into tables using connection strings. The interaction of SQL Server of ELMAH. ReferencesScott Hanselman Blog Wiki.
ASP.NET MVC 5 Recipes: A Practical Solution