title: Registering a IExceptionLogger OWIN versus WebApiConfig
body: <p>We have a set of RestFul services developed using WebApi 2. These will be hosted on Azure. I have an implementation of the IExceptionLogger to log all unhandled exceptions. </p>
  
  <p>The logger can be registered in the pipeline as follows</p>
  
  <pre><code>    public static class WebApiConfig
      {
          public static void Register(HttpConfiguration config)
          {
              //Register the ExceptionLogger
              config.Services.Add(typeof(IExceptionLogger), new UnhandledExceptionLogger());
  
              config.MapHttpAttributeRoutes();
  
              config.Routes.MapHttpRoute(
                  name: "DefaultApi",
                  routeTemplate: "api/{controller}/{id}",
                  defaults: new { id = RouteParameter.Optional }
              );
          }
      }
  </code></pre>
  
  <p>Or it could be setup as a Owin middleware as follows </p>
  
  <pre><code>public static class SetupExceptionHandlers
  {
      public static IAppBuilder SetupFilters(this IAppBuilder builder, HttpConfiguration config)
      {
          config.Services.Add(typeof(IExceptionLogger), new UnhandledExceptionLogger());
  
          return builder;
      }   
  }
  </code></pre>
  
  <p>And then registered in the pipeline as follows</p>
  
  <pre><code>    public class Startup
      {
          public void Configuration(IAppBuilder app)
          {
              var config = new HttpConfiguration();
              app.SetupFilters(config);
              app.UseStageMarker(PipelineStage.Authenticate);
          }
      }
  </code></pre>
  
  <p>Trying to understand what the better/correct way to do this is. I have registered it both ways and don't see any difference in the behavior. I have also tried to keep both the registrations at the same time and it still works(no exceptions).</p>