In ASP.NET Core 2.0 we have this
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
That CreateDefaultBuilder(args) has many helpful defaults. However it contains this:
.ConfigureLogging((context, logging) => {
logging.AddConfiguration(context.Configuration.GetSection("Logging"));
logging.AddConsole(); // HERE IS THE PROBLEM
logging.AddDebug(); // HERE IS THE PROBLEM
})
So the console and debug logging providers are always registered.
I used to register them like this
if (env.IsDevelopment())
{
// register them here
}
How do I remove/unregister them when running in production mode? I don't mean changing the logging level, I mean I don't want them registered at all in production mode.
CreateDefaultBuilderwas created to ease setup (aggregate lots of common stuff) a new project. Before final 2.0 there was noDefaultBuilder. I would suggest you to copy the code from the source code you´ve just linked and change it by your own, as I said,CreateDefaultBuilderis just to ease this step. Take a look how it was done before: learn.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/… . Regards.