title: Inject dependency into DelegatingHandler
body: <p>I am new to dependency injection, but happy with <code>Ninject</code> and <code>Ninject.Extensions.Logging</code> to <code>[Inject]</code> my <code>ILogger</code> wherever i need it.</p>
  
  <p>However some <strong>DelegatingHandlers</strong> are spoiling all the fun.</p>
  
  <pre><code>public class HttpsHandler : DelegatingHandler
  {
      [Inject]
      public ILogger Logger { get; set; }
  
      protected override Task&lt;HttpResponseMessage&gt; SendAsync(
              HttpRequestMessage request, CancellationToken cancellationToken)
          {
              if (!string.Equals(request.RequestUri.Scheme, "https", StringComparison.OrdinalIgnoreCase))
              {
                  Logger.Info(String.Format("{0}: is using HTTP", request.RemoteAddress());
                  return
                      Task.Factory.StartNew(
                          () =&gt;
                          new HttpResponseMessage(HttpStatusCode.BadRequest)
                          {
                              Content = new StringContent("HTTPS Required")
                          });
              }
  
              return base.SendAsync(request, cancellationToken);
          }
   }
  </code></pre>
  
  <p>Could anyone point me in the right direction on how to Inject Ninject.Extensions.Logger.Nlog2 into Ilogger inside the delegatinghandlers?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I think Pete got me in the right direction in the comments (thanks!).
  I added the following constructor to the <code>HttpsHandler</code>:</p>
  
  <pre><code>public HttpsHandler()
          {
              var kernel = new StandardKernel();
  
              var logfactory = kernel.Get&lt;ILoggerFactory&gt;();
              this.Logger = logfactory.GetCurrentClassLogger();
          }
  </code></pre>
  
  <p>and now i've got the Logger working!</p>
  
  <p>My only question left, is this the <em>right</em> way to do it, or is it a anti-pattern?</p>