title: Using LogManager.GetLogger with Unity
body: <p>Given this class:</p>
  
  <pre><code>class Foo
  {
      readonly ILog log;
  
      public Foo(ILog log)
      {
          this.log = log;
      } 
  
      ...
  }
  </code></pre>
  
  <p>I'd like to configure Unity to inject ILog. That's easy:</p>
  
  <pre><code>container.RegisterInstance&lt;ILog&gt;(LogManager.GetLogger(typeof(XYZ)));
  </code></pre>
  
  <p>But I'd like to make Unity call <code>LogManager.GetLogger</code> with the type of the parent type being resolved. </p>
  
  <p>This is close:</p>
  
  <pre><code>container.RegisterType&lt;ILog&gt;(new InjectionFactory((c, t, s) =&gt; LogManager.GetLogger(t)));
  </code></pre>
  
  <p>But <code>t</code> in this case is the type being resolved (<code>ILog</code>), not the type that the object is being resolved for (<code>Foo</code>). </p>
  
  <p>I know I can do this:</p>
  
  <pre><code>container.RegisterType&lt;Foo&gt;(new InjectionFactory(c =&gt; new Foo(LogManager.GetLogger(typeof(Foo)));
  </code></pre>
  
  <p>But I don't want to have to add that crazy declaration every time I register an object. </p>
  
  <p>I know this can be done in Autofac, and I know the Real Answer is not to use Unity in the first place, but can this be done? :) </p>