Skip to content

Instantly share code, notes, and snippets.

@odugen
Created December 10, 2012 11:01
Show Gist options
  • Select an option

  • Save odugen/4249988 to your computer and use it in GitHub Desktop.

Select an option

Save odugen/4249988 to your computer and use it in GitHub Desktop.
Elmah.MVC Web API configuration
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);
}
}
}
@odugen
Copy link
Author

odugen commented Dec 10, 2012

Configuration needed to make ELAMH work with Web API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment