title: How to get ILogger<T> in this scenario
body: <p>I've got the following class currently:</p>
  <pre><code>public sealed class WmiMethod
  {
      private readonly string _methodName;
      private readonly ManagementClass _mc;
      private readonly ManagementBaseObject? _inParams;
  
      private WmiMethod(Type type, string methodName)
      {
          _mc = TypeHelper.GetManagementClass(type);
          _methodName = methodName;
          _inParams = _mc.GetMethodParameters(_methodName);
      }
  
      public static WmiMethod Get&lt;T&gt;([CallerMemberName] string methodName = &quot;&quot;)
      {
          return new(typeof(T), methodName);
      }
  
      public ManagementBaseObject InvokeStatic(params object[] parameters)
      {
          // Stuff
      }
  }
  </code></pre>
  <p>The idea behind the <code>Get&lt;T&gt;()</code> method is to allow the whole class to work seamlessly with <code>[CallerMemberName]</code> and <code>params</code>, so that the caller can do <code>WmiMethod.Get&lt;T&gt;().InvokeStatic(&quot;my&quot;, &quot;parameters&quot;, 1)</code> for example.</p>
  <p>Now I would like to introduce logging, ideally with <code>ILogger&lt;WmiMethod&gt;</code> as I'm using ASP.NET and DI but clearly in this case the instances of the class are constructed by the caller which will not have any idea of how to create an <code>ILogger&lt;WmiMethod&gt;</code>.</p>
  <p>The way I see it the options I have are either to use <code>ILogger</code> instead of <code>ILogger&lt;WmiMethod&gt;</code> or to have an <code>ILogger&lt;WmiMethod&gt;</code> injected to the caller so that the caller can pass it to <code>WmiMethod.Get&lt;T&gt;(ILogger&lt;WmiMethod&gt; logger)</code>, but I'm wondering if there are other better alternatives here.</p>