<p>I wrote few web APIs in .net core 2.0 and deployed it using a docker container inside a Kubernetes cluster. I am using the below logging configuration but can't see any logs inside the Kubernetes pod console. Am I missing something here?:</p>
<p>Logging section in appsettings.json &amp; appsettings.Development.json</p>
<pre><code>{
  &quot;Logging&quot;: {
    &quot;IncludeScopes&quot;: true,
    &quot;LogLevel&quot;: {
      &quot;Default&quot;: &quot;Debug&quot;,
      &quot;System&quot;: &quot;Information&quot;,
      &quot;Microsoft&quot;: &quot;Information&quot;
    },
    &quot;Console&quot;: {
      &quot;LogLevel&quot;: {
        &quot;Default&quot;: &quot;Information&quot;,
        &quot;System&quot;: &quot;Information&quot;,
        &quot;Microsoft&quot;: &quot;Information&quot;
      }
    }
  }
}
</code></pre>
<p>Inside Program.cs:</p>
<pre><code>public static IWebHost BuildWebHost(string[] args)
{
    return new WebHostBuilder()
        .UseKestrel()
        .ConfigureAppConfiguration((hostingContext, config) =&gt;
        {
            var env = hostingContext.HostingEnvironment;

            config.AddJsonFile(&quot;appsettings.json&quot;, optional: true, reloadOnChange: true)
                .AddJsonFile($&quot;appsettings.{env.EnvironmentName}.json&quot;, optional: true, reloadOnChange: true);

            if (env.IsDevelopment())
            {
                var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName));
                if (appAssembly != null)
                {
                    config.AddUserSecrets(appAssembly, optional: true);
                }
            }

            config.AddEnvironmentVariables();

            if (args != null)
            {
                config.AddCommandLine(args);
            }
        })
        .ConfigureLogging((hostingContext, logging) =&gt;
        {
            logging.AddConfiguration(hostingContext.Configuration.GetSection(&quot;Logging&quot;));
            logging.AddConsole();
            logging.AddDebug();
        })
        .UseDefaultServiceProvider((context, options) =&gt;
        {
            options.ValidateScopes = context.HostingEnvironment.IsDevelopment();
        })
        .UseStartup&lt;Startup&gt;()
        .Build();
}
</code></pre>
<p>Example of logging in other classes:</p>
<pre><code>_logger.LogInformation(&quot;This log should go in kubernetes pod console&quot;);
</code></pre>

<p>Have you attempted to DI common third-party packages built for powerful logging instead? That might suit your needs! The code below shows how Serilog is injected in <code>Program.cs</code> and can be used to output its logs through several channels of your choice (I'm personally using minikube locally on macOS along with a staging environment on GCP).</p>
<pre><code>WebHost.CreateDefaultBuilder(args)
                .UseSerilog((context, configuration) =&gt;
                {
                    configuration
                        .MinimumLevel.Debug()
                        .MinimumLevel.Override(&quot;Microsoft&quot;, LogEventLevel.Warning)
                        .MinimumLevel.Override(&quot;System&quot;, LogEventLevel.Warning)
                        .MinimumLevel.Override(&quot;Microsoft.AspNetCore.Authentication&quot;, LogEventLevel.Information)
                        .Enrich.FromLogContext()
                        .WriteTo.Console(
                            outputTemplate:
                            &quot;[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}&quot;,
                            theme: AnsiConsoleTheme.Literate);
                })
</code></pre>
<p>The desired output from the above would look something like that in Kubernetes:</p>
<pre><code> xxxxx@iMac  ~/Projects/xxxxx   xxxxbranch/xxx-xxx  kubectl logs xxxx-xxxx-6b9dd8dc67-vc9ch
[2020-08-04 12:11:37 Warning] Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository
Storing keys in a directory '/xxxxxxxxx/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.

[2020-08-04 12:11:37 Warning] Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager
No XML encryptor configured. Key {xxxxxx} may be persisted to storage in unencrypted form.

[2020-08-04 12:11:37 Warning] Microsoft.AspNetCore.Server.Kestrel
Overriding address(es) 'https://+:8081'. Binding to endpoints defined in UseKestrel() instead.

Hosting environment: Production
Content root path: /app
Now listening on: https://0.0.0.0:8081
Application started. Press Ctrl+C to shut down.
</code></pre>
<p>These outputs are also stashed in Google Cloud's Logging dashboard.</p>
