title: How to use Microsoft.Extensions.Logging in a .NET Core 3.0 Worker Service
body: <p>I started a new Windows service project and decided to use the .NET Core 3.0 Worker Service template. This service will never be used in a cloud/web project, but there's a chance I might want to adapt it to run on Linux at some point.</p>
  
  <p>I'm very familiar with the use of NLog for logging. The model of creating a new static logger object within every class is very intuitive. I see that the Worker Service has the <code>Microsoft.Extensions.Logging</code> framework baked in, to the point that the default worker has an <code>ILogger&lt;Worker&gt;</code> passed right in. That's great for "my first service", but what about a real long-running service with lots of classes, each requiring logging?</p>
  
  <p>All the tutorials I find for this template deal with services which do all the work and logging in the Worker class. For historical reasons, most logging articles consider only ASP.NET core, in which DI is a priority. I have not found any description of how to build an app with a tree of multiple long-lived classes, each of which has its own <code>ILogger</code> object to write to. </p>
  
  <p>Even though I will never need DI in this project, it seems like it might be a good standard to adopt across my code base, initially hooking it up to the NLog provider. I could grab the <code>IHostBuilder</code> in my <code>Main</code>, then as add a static function to create loggers from its <code>ILoggingBuilder</code> in a similar way to NLog, but I can't believe that's the best way.</p>
  
  <p>Is there an established best practice here? Does it involve unpicking some of the magic from the Worker Service template?</p>