How to log debug messages in ASP.NET Core (ASP.NET 5)

I've been getting to grips with ASP.NET 5 (now ASP.NET Core 1.0) over the past few weeks and recently wanted to log out some debug messages from some custom middleware:

log.LogDebug("Setting current tenant.");

In startup.cs I added the following to ConfigureServices:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    loggerFactory.MinimumLevel = LogLevel.Debug;


The default log level in ASP.NET 5 is Information. However, even after setting the MinimumLevel to Debug I still couldn't see my debug messages.

It turns out that the Console Logger also defaults to LogLevel.Information which means that the debug messages get dropped. The solution is to explicitly set the log level of the logging provider, in this case:


After doing this, my debug messages were displayed.

Note that you need to set both the ILoggerFactory.MinimumLevel and logging level of the logging provider to Debug - it's confusing I know. I guess this is a "safe by default" setting so that sensitive information doesn't find it's way into your production logs.

If passing a configuration section to the logging provider (like the standard ASP.NET 5 MVC template does), set the value for the default category in appsettings.json:

  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"

Ben Foster

About Me

I'm a software engineer and aspiring entrepreneur with 15 years experience in tech and have worked with companies of all sizes in areas such as healthcare, agriculture, recruitment, e-commerce and finance. I founded my first startup Fabrik in 2011.

I now head up the engineering team at If you're interested in working in an exciting and innovative fin-tech company, drop me a message.

Creative Commons Licence