title: How to enable Trace logging in ASP.NET Core?
body: <p>I cannot get basice <code>LogTrace(...)</code> output in my application. Here's a repro:</p>
  
  <ol>
  <li>Create a new ASP.NET Core application using Visual Studio 2017.</li>
  <li>(Optional) comment out <code>.UseApplicationInsights()</code> so the repro is clearer</li>
  <li><p>Replace the code in <code>ValuesController.cs</code> with this:</p>
  
  <pre><code>using System.Collections.Generic;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.Extensions.Logging;
  
  namespace WebApplication1.Controllers
  {
      [Route("api/[controller]")]
      public class ValuesController : Controller
      {
          private readonly ILogger&lt;ValuesController&gt; logger;
  
          public ValuesController(ILogger&lt;ValuesController&gt; logger)
          {
              this.logger = logger;
          }
  
          [HttpGet]
          public IEnumerable&lt;string&gt; Get()
          {
              logger.LogError("ERROR!");
              logger.LogWarning("WARN!");
              logger.LogInformation("INFO!");
              logger.LogTrace("TRACE!");
              return new string[] { "value1", "value2" };
          }
      }
  }
  </code></pre></li>
  <li><p>Change <code>appsettings.Development.json</code> to this:</p>
  
  <pre><code>{
    "Logging": {
      "IncludeScopes": false,
      "LogLevel": {
        "Default": "Trace",
        "System": "Information",
        "Microsoft": "Information"
      }
    }
  }
  </code></pre></li>
  <li><p>Run and view the Debug output</p></li>
  </ol>
  
  <p>This leads to:</p>
  
  <ul>
  <li><p>Actual output:</p>
  
  <p><a href="https://i.stack.imgur.com/07Msc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/07Msc.png" alt="only ERROR, WARN, and INFO"></a></p></li>
  <li><p>Expected output would be the "TRACE!" message as well</p></li>
  </ul>
  
  <p>I've tried tweaking the values in the <code>appsettings.json</code> file as well, but that had no effect either.</p>
  
  <p>Weirdly, changing the value in either file to <code>"Error"</code> doesn't do anything either.</p>
  
  <h3>Bottom Line / Question</h3>
  
  <p>What do I need to do to make my injected <code>ILogger&lt;ValuesController&gt;</code> respect the logging settings, including <code>Trace</code> level?</p>
  
  <hr>
  
  <h3>Footnote</h3>
  
  <p>Here's some of the relevant code that would be auto-generated with the above repro:</p>
  
  <p><code>Startup.cs</code></p>
  
  <pre><code>public class Startup
  {
      public Startup(IHostingEnvironment env)
      {
          var builder = new ConfigurationBuilder()
              .SetBasePath(env.ContentRootPath)
              .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
              .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
              .AddEnvironmentVariables();
          Configuration = builder.Build();
      }
  
      public IConfigurationRoot Configuration { get; }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          // Add framework services.
          services.AddMvc();
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
      {
          loggerFactory.AddConsole(Configuration.GetSection("Logging"));
          loggerFactory.AddDebug();
  
          app.UseMvc();
      }
  }
  </code></pre>
  
  <p><code>Program.cs</code></p>
  
  <pre><code>public class Program
  {
      public static void Main(string[] args)
      {
          var host = new WebHostBuilder()
              .UseKestrel()
              .UseContentRoot(Directory.GetCurrentDirectory())
              .UseIISIntegration()
              .UseStartup&lt;Startup&gt;()
              .UseApplicationInsights()
              .Build();
  
          host.Run();
      }
  }
  </code></pre>
  
  <p><code>appsettings.json</code> default:</p>
  
  <pre><code>{
    "Logging": {
      "IncludeScopes": false,
      "LogLevel": {
        "Default": "Warning"
      }
    }
  }
  </code></pre>