title: Inject Logger in IExceptionFilter with SimpleInjector
body: <p>I'm using Simple Injector in an ASP.NET Core 2.1 WebAPI application. I have an IExceptionFilter in which I want to log the error. My code is below (working), but is this the correct way? It looks like lot of work</p>
  
  <pre><code>public class HttpGlobalExceptionFilter : IExceptionFilter
  {
      private readonly ILogger logger;
  
      public HttpGlobalExceptionFilter(Infrastructure.Common.ILogger logger)
      {
          // This is my own logger, implemented along the lines as mentioned here:
          // https://stackoverflow.com/questions/41243485/
          this.logger = logger;
      }
  
      public void OnException(ExceptionContext context)
      {
          // Irrelevant stuff
          // ...
  
          var error = $"An error occured: {context.Exception.Message}";
          this.logger.LogError(error);
          context.ExceptionHandled = true;
      }
  }
  </code></pre>
  
  <p>In my Startup.cs ConfigureServices(), I have:</p>
  
  <pre><code>services.AddMvc(options =&gt;
  {
      options.Filters.Add(new SimpleInjectorExceptionFilterDispatcher(
          this.container.GetInstance&lt;IExceptionFilter&gt;));
      // ...
  });
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>services.AddMvc(options =&gt;
  {
      options.Filters.Add&lt;HttpGlobalExceptionFilter&gt;();
      // ...
  });
  </code></pre>
  
  <p>In my bindings:</p>
  
  <pre><code>container.Register&lt;IExceptionFilter, HttpGlobalExceptionFilter&gt;();
  </code></pre>
  
  <p>Finally, the dispatcher:</p>
  
  <pre><code>public sealed class SimpleInjectorExceptionFilterDispatcher : IExceptionFilter
  {
      private readonly Func&lt;IExceptionFilter&gt; exceptionFilterFunc;
  
      public SimpleInjectorExceptionFilterDispatcher(
          Func&lt;IExceptionFilter&gt; exceptionFilterFunc)
      {
          this.exceptionFilterFunc = exceptionFilterFunc;
      }
  
      public void OnException(ExceptionContext context)
      {
          this.exceptionFilterFunc.Invoke().OnException(context);
      }
  }
  </code></pre>
  
  <p>Is this the way to go about getting Simple Injector work with different components of ASP.NET? This is complex setup, and I would prefer to have something simpler so that all developers can easily understand the code. </p>
  
  <p>Also, can I totally avoid Microsoft DI and use Simple Injector (and expect simpler configurations?)</p>
  
  <p>References:</p>
  
  <p><a href="https://stackoverflow.com/questions/31953921/simple-injector-inject-dependency-into-custom-global-authentication-filters-and">Simple Injector inject dependency into custom global authentication filters and OWIN middle ware OAuthAuthorizationServerProvider</a></p>
  
  <p><a href="https://stackoverflow.com/questions/41243485/simple-injector-register-iloggert-by-using-iloggerfactory-createloggert">Simple Injector: Register ILogger&lt;T&gt; by using ILoggerFactory.CreateLogger&lt;T&gt;()</a></p>