title: Serilog WriteTo.File() works in Console App but not in .net Core 3 Worker Service
body: <p>The code below for init of a LoggerConfiguration() works in the Main() of a .net core 3 console application, but not in a worker service. With the console application the 'logs' folder and log.txt were created at run time. The folder was not created when running the service, so I tried multiple file paths ("c:\log.txt", "..\log.txt", "..\..\log.txt") none of which were created. Logging is showing in the Debug Console, but no log.txt file is created. No error is thrown, VS 2019 is running as administrator.</p>
  
  <p>Referenced Packages:</p>
  
  <pre><code>&lt;PackageReference Include="Serilog" Version="2.9.0" /&gt;
  &lt;PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /&gt;
  &lt;PackageReference Include="Serilog.Sinks.File" Version="4.1.0" /&gt;
  </code></pre>
  
  <p>Program.cs:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.Extensions.DependencyInjection;
  using Microsoft.Extensions.Hosting;
  using Serilog;
  
  namespace WorkerService1
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              Log.Logger = new LoggerConfiguration()
                  .MinimumLevel.Debug()
                  .WriteTo.Console()
                  .WriteTo.File("logs\\log.txt", rollingInterval: RollingInterval.Day)
                  .CreateLogger();
  
              CreateHostBuilder(args).Build().Run();
          }
  
          public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
              Host.CreateDefaultBuilder(args)
                  .ConfigureServices((hostContext, services) =&gt;
                  {
                      services.AddHostedService&lt;Worker&gt;();
                  });
      }
  }
  </code></pre>
  
  <p>Worker.cs:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading;
  using System.Threading.Tasks;
  using Microsoft.Extensions.Hosting;
  using Microsoft.Extensions.Logging;
  
  namespace WorkerService1
  {
      public class Worker : BackgroundService
      {
          private readonly ILogger&lt;Worker&gt; _logger;
  
          public Worker(ILogger&lt;Worker&gt; logger)
          {
              _logger = logger;
          }
  
          protected override async Task ExecuteAsync(CancellationToken stoppingToken)
          {
              while (!stoppingToken.IsCancellationRequested)
              {
                  _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
                  await Task.Delay(1000, stoppingToken);
              }
          }
      }
  }
  
  </code></pre>