Created
December 10, 2012 11:01
-
-
Save odugen/4249988 to your computer and use it in GitHub Desktop.
Elmah.MVC Web API configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Mvc | |
| { | |
| public class FilterConfig | |
| { | |
| public static void RegisterGlobalFilters(GlobalFilterCollection filters) | |
| { | |
| GlobalConfiguration.Configuration.Filters.Add(new ElmahHandledErrorLoggerFilter()); | |
| filters.Add(new HandleErrorAttribute()); | |
| } | |
| } | |
| /// <summary> | |
| /// Part time fix to log Web API errors to ELMAH. | |
| /// Need to push one line change to https://github.com/alexanderbeletsky/elmah.mvc/ and get nuget package updated | |
| /// </summary> | |
| public class ElmahHandledErrorLoggerFilter : ExceptionFilterAttribute | |
| { | |
| public override void OnException(HttpActionExecutedContext actionExecutedContext) | |
| { | |
| base.OnException(actionExecutedContext); | |
| ErrorSignal.FromCurrentContext().Raise(actionExecutedContext.Exception); | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Configuration needed to make ELAMH work with Web API