Available on NuGet
Including ELFAR (MVC) and ELFAR (Web API) in your web application is extremely easy. However, if you're anything like me then you'll hate the idea of having to create two instances of the error log provider (assuming that you've referenced the same providers). You can manually combine the files but, to save you the bother, I've done the leg work for you:
There has been a steady uptake of Error Logging Filter and Route (ELFAR) for ASP.NET MVC since I introduced it, back in February. Just a few days before that post, Microsoft released ASP.NET MVC 4 Beta (now RC), which includes ASP.NET Web API. Although part of ASP.NET MVC 4, ASP.NET Web API uses completely different namespaces (and can be hosted independently), which means that ELFAR couldn't be plugged in automatically, so I decided to see if it was possible to adapt ELFAR for ASP.NET Web API.
As the two technologies follow the same architecture, it was a simple process to create the Web API ErrorLogFilter and ErrorLogRoute. They are almost identical to the MVC ErrorLogFilter and ErrorLogRoute, apart from the base classes that they derive from (and the Web API ErrorLogRoute doesn't need to override the GetRouteData or GetVirtualPath methods). However, to maintain the separation of concerns between ASP.NET MVC and ASP.NET Web API, the common interfaces and classes needed to be moved out of the MVC class library and into their own class library (Elfar.Core). With that, Error Logging Filter and Route (ELFAR) for ASP.NET Web API was created.
Like ELFAR (MVC), add ELFAR (Web API) to your website/web application with just 4 lines of code (usually in the Application_Start method):
var config = GlobalConfiguration.Configuration;Figure 1
var provider = new ErrorLogProvider();
config.Routes.Add("elfar", new ErrorLogRoute(provider));
The same but different
Whilst the filters behave identically, the routes provide very different functionality. Where the MVC version provides the web GUI, for viewing the error logs, the Web API version acts as an ErrorLogProvider by returning either the list of error logs or a single error log.
Available on NuGet
ELFAR (Web API) uses the same error log providers as ELFAR (MVC):