title: dotnet core-Logging in class library
body: <p>is it possible to use <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging" rel="nofollow noreferrer">Microsoft.Extensions.Logging</a> like use logging in controllers(put in constructor and framework handle it with DI), in class library which my ASP.NET Core web application use that library? and how instantiate class and use method?</p>
  
  <pre><code>public class MyMathCalculator
  {
      private readonly ILogger&lt;MyMathCalculator&gt; logger;
  
      public MyMathCalculator(ILogger&lt;MyMathCalculator&gt; logger)
      {
          this.logger = logger;
      }
  
      public int Fact(int n)
      {
          //logger.LogInformation($"Fact({n}) called.");
          if (n == 0)
          {
              return 1;
          }
          return Fact(n - 1) * n;
      }
  }
  </code></pre>