Logging to elmah.io from ASP.NET MVC
Even though ELMAH works out of the box with ASP.NET MVC, ELMAH and MVC provide some features which interfere with one another. As usual, the great community around ELMAH has done something to fix this, by using the Elmah.Mvc NuGet package. We've built a package for ASP.NET MVC exclusively, which installs all the necessary packages.
To start logging exceptions from ASP.NET MVC, install the Elmah.Io.Mvc
NuGet package:
Install-Package Elmah.Io.Mvc
dotnet add package Elmah.Io.Mvc
<PackageReference Include="Elmah.Io.Mvc" Version="5.*" />
paket add Elmah.Io.Mvc
During the installation, you will be asked for your API key (Where is my API key?) and log ID (Where is my log ID?). That's it. Every unhandled exception in ASP.NET MVC is logged to elmah.io.
As part of the installation, we also installed Elmah.MVC
, which adds some interesting logic around routing and authentication. Take a look in the web.config
for application settings with the elmah.mvc.
prefix. For documentation about these settings, check out the Elmah.MVC project on GitHub.
Since Elmah.MVC
configures an URL for accessing the ELMAH UI (just /elmah
and not /elmah.axd
), you can remove the location
element in web.config
, added by the Elmah.Io.Mvc
NuGet package installer.
This article was brought to you by the elmah.io team. elmah.io is the best error management system for .NET web applications. We monitor your website, alert you when errors start happening, and help you fix errors fast.
See how we can help you monitor your website for crashes Monitor your website