title: Serilog configuration read depending on the Environment variable in Worker service in .Net 5
body: <p>I have different configurations for Serilog based on the Environment variable. And they are written in the appsettings.json and appsetting.Development.json. My problem is when configuring logger it does not read from the appsettings.Development.json even in Development mode.</p>
  <p>I've tried to configure it like this,</p>
  <pre><code>.ConfigureAppConfiguration((w, c) =&gt;
        {
            var env = w.HostingEnvironment;
            if (env.EnvironmentName == &quot;Development&quot;)
            {
                 c.AddCustomJsonFile($&quot;appsettings.{env.EnvironmentName}.json&quot;);
            }
            else
            {
                 c.AddCustomJsonFile($&quot;appsettings.json&quot;);
            }
       })
  .ConfigureServices((hostContext, services) =&gt;
        {
           Log.Logger = new LoggerConfiguration()
               .ReadFrom.Configuration(hostContext.Configuration)
               .CreateLogger();
        }).UseSerilog();
  </code></pre>
  <p>And my appsettings.json is like this,</p>
  <pre><code>&quot;Serilog&quot;: {
  &quot;MinimumLevel&quot;: {
    &quot;Defult&quot;: &quot;Information&quot;,
    &quot;Override&quot;: {
      &quot;Micorsoft&quot;: &quot;Warning&quot;,
      &quot;System&quot;: &quot;Information&quot;
    }
  },
  &quot;WriteTo&quot;: [
    { &quot;Name&quot;: &quot;Console&quot; },
    {
      &quot;Name&quot;: &quot;Seq&quot;,
      &quot;Args&quot;: {
        &quot;serverUrl&quot;: &quot;http://localhost:5341/&quot;
      }
    }
  ]
  </code></pre>
  <p>And in appsetting.Development.json,</p>
  <pre><code>&quot;Serilog&quot;: {
  &quot;MinimumLevel&quot;: {
    &quot;Defult&quot;: &quot;Debug&quot;,
    &quot;Override&quot;: {
      &quot;Micorsoft&quot;: &quot;Warning&quot;,
      &quot;System&quot;: &quot;Information&quot;
    }
  },
  &quot;WriteTo&quot;: [
    { &quot;Name&quot;: &quot;Console&quot; },
    {
      &quot;Name&quot;: &quot;Seq&quot;,
      &quot;Args&quot;: {
        &quot;serverUrl&quot;: &quot;http://localhost:5341/&quot;
      }
    }
  ]
  </code></pre>
  <p>I've tested it with other services where it uses the correct appsettings based on the environment variable, Just Serilog is having problems with this. Does anybody know how to solve this?
  Thanks in advance.</p>