Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elmah.MVC vs. Elmah.contrib.Mvc

I'm new to ASP.NET MVC and I'm looking for the least painful way to get global error handling, logging, and reporting (via email) set up. FYI, my ASP.NET MVC app is being hosted as a web role in Azure, but I'm trying to avoid using any Azure-specific hooks.

It looks like getting ELMAH installed and configured is a good first step.

When I look in NuGet, I see:

  • ELMAH ("ELMAH with initial configuration for getting started quickly...")
  • Elmah.Contrib.Mvc ("...designed to add ease-of-use inside MVC projects...")
  • Elmah.MVC ("...painless integration into MVC...")

Which of these packages do I want to install?

EDIT: After some experimentation, I'm more confused. I compared the project files after installing each of the three options on top of a default MVC 4 app. It appears that neither Elmah.Contrib.Mvc nor Elmah.MVC add the elmah.1.2.2 package (which I get when I install basic ELMAH). Also, neither package adds the <elmah> section to Web.config.

So... do I need to install ELMAH first, and then install one of the "...MVC" packages to get whatever nifty improvements they presumably get me?

like image 838
Bob.at.Indigo.Health Avatar asked Mar 22 '13 22:03

Bob.at.Indigo.Health


People also ask

What is Elmah MVC?

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.


2 Answers

ELMAH - This is the default ELMAH package with no mvc specific code in it, if you dont do what is described here I don't believe ELMAH will log any errors that occur in you're controllers, and you may not be able to access the ELMAH log page

Elmah.Contrib.Mvc - This is an enhancement on ELMAH specifically for MVC based upon one of the creators of ELMAHS answer to a stack overflow question.

Elmah.MVC - This is simliar to the above package however I believe it provides much better support for mvc features like routes etc, It is also quite easy to install and configure, it removes a lot of the messing around you would have to do with ELMAH to take out various parts that arent required when running in a mvc project

You can read the authors posts to get a better idea of how it works:

  • Integrating ELMAH to ASP.NET MVC in right way
  • ELMAH MVC controller released on NuGet
  • ELMAH.MVC v.2.0.0 - Release Candidate

Personally I believe the last package would be the best one ot use, it seems to be the more up to date and maintained of the two mvc ones.

like image 161
Daniel Powell Avatar answered Sep 22 '22 20:09

Daniel Powell


You might consider using Elfar instead of Elmah. Elfar is "inspired" by Elmah but is designed to be MVC specific and is very simple to configure.

Just open NuGet, and search for Elfar. You will find a number of different packages, but in general you want the one that conforms to the technology you are intested in using. I'm not familiar with Azure web roles, but if you have access to a standard Sql Server then you can simply use Elfar.SqlClient.

More info here:

https://github.com/stevenbey/elfar/wiki

like image 32
Erik Funkenbusch Avatar answered Sep 24 '22 20:09

Erik Funkenbusch