Duplicate info messages in console of Web API after upgrading to ASP.NET Core 2.0

WebHost.CreateDefaultBuilder sets up a lot of the conventional stuff for you, to save the same code having to be generated for each individual ASP.NET Core 2 project (as it was in ASP.NET Core 1.x).

You can see the code for WebHost.CreateDefaultBuilder here. For your particular scenario, if you look a little further down in the source code, you'll see the following:

logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
logging.AddDebug();

Due to this, you no longer need to add this code yourself. In doing so, it gets added twice and this ends up doing the logging twice.

If you want a more detailed walkthrough of these changes, Andrew Lock has a good write-up of how this works. He also digs into some of the details of how to override some of these defaults, etc. Note that this write-up is based on ASP.NET Core 2 preview 1, but things are more or less the same in the final version.


I was having the same issue: using NLog, all info was duplicated and recorded that way. For me, what solved the problem was to remove the loggerFactory.AddNLog() from Configure at Startup.cs. I'm using Core 2.0.