Logging errors in ASP.NET MVC

I would consider simplifying your web application by plugging in Elmah.

You add the Elmah assembly to your project and then configure your web.config. It will then log exceptions created at controller or page level. It can be configured to log to various different places (like SQL Server, Email etc). It also provides a web frontend, so that you can browse through the log of exceptions.

Its the first thing I add to any asp.net mvc app I create.

I still use log4net, but I tend to use it for logging debug/info, and leave all exceptions to Elmah.

You can also find more information in the question How do you log errors (Exceptions) in your ASP.NET apps?.

Leave a Comment