title: How to dependency inject Serilog into the rest of my classes in .NET Console App
body: <p>I'm getting started with <a href="https://github.com/serilog/serilog" rel="nofollow noreferrer">Serilog</a> but I don't know how to dependency inject the ILogger into my classes. It's easy if I was using ASP.NET Core 5, but I'm using a .NET Core Console App. How can I do similarly?</p>
  <h3>Before with log4net:</h3>
  <pre class="lang-cs prettyprint-override"><code>public class TestStrategy
  {
      private static readonly ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.Name);
  
      ...
  }
  </code></pre>
  <h3>My Serilog logger creation:</h3>
  <pre class="lang-cs prettyprint-override"><code>var configuration = new ConfigurationBuilder()
      .AddJsonFile(&quot;appsettings.json&quot;)
      .Build();
  
  var logger = new LoggerConfiguration()
      .ReadFrom.Configuration(configuration)
      .CreateLogger();
  </code></pre>
  <p>Do I have to DI <code>logger</code> into all classes?</p>