Wednesday, August 17, 2016

Using ELMAH to log exceptions/errors in an ASP.NET MVC Web Application

Now that Microsoft's Application Blocks are no longer under active development, I began looking for alternatives to the Exception and Logging Application Blocks for my ASP.NET MVC Web Applications.

Fortunately, ELMAH has a NuGet package especially for ASP.NET MVC Web Applications!  The other nice thing about ELMAH is that it also provides a nice web-based User Interface for you to view your Exception/Error Logs which is not provided by the Microsoft Exception and Logging Application Blocks:

Once you have installed ELMAH into your ASP.NET MVC Web Application, it is still not configured for your application by default!

You still have to go into your Web.config and configure your ELMAH settings for logging and security.

In fact, if you do  not configure your ELMAH settings, when you navigate to the /elmah Url of your ASP.NET MVC Web Application, you will probably get a screen similar to the following:

If you are using this for your own development environment, security may not be much of a concern, and you may not also require a database so you can use the following Web.config settings for your ELMAH Configuration Section:

If everything is configured correctly for ELMAH in your Web.config file, you should now get this screen instead when you navigate to the /elmah Url:

You can read more about setting up and configuring ELMAH here:

For configuring ELMAH with ASP.NET MVC:

For securing your ELMAH Error Log pages:

No comments:

Post a Comment