title: ASP.NET Core API - Why does logger type match controller class?
body: <p>In this code example for creating a logging instance using Dependency Injection in ASP.NET Core why is the logger type the controller class when injecting the logger in the constructor?</p>
  
  <pre><code>ILogger&lt;TodoController&gt; logger
  </code></pre>
  
  <p>Instead of <code>ILogger&lt;TodoController&gt;</code> shouldn't it be just <code>ILogger logger</code> passed into the constructor? </p>
  
  <p>Code example:</p>
  
  <pre><code>public class TodoController : Controller
  {
      private readonly ITodoRepository _todoRepository;
      private readonly ILogger _logger;
  
      public TodoController(ITodoRepository todoRepository,
          ILogger&lt;TodoController&gt; logger)
      {
          _todoRepository = todoRepository;
          _logger = logger;
      }
  </code></pre>
  
  <p>Source: <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?tabs=aspnetcore2x&amp;view=aspnetcore-2.2" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?tabs=aspnetcore2x&amp;view=aspnetcore-2.2</a></p>