aspnet / Templates

This repo is OBSOLETE - please see the README file for information
Other
150 stars 57 forks source link

Configure logging from Program.Main() instead of injecting ILoggerFactory in Startup.Configure #586

Closed kevinchalet closed 7 years ago

kevinchalet commented 8 years ago

Currently, the logging listeners are added in Startup.Configure. Ideally, the ASP.NET Core templates should use the new WebHostBuilder.ConfigureLogging method instead of injecting ILoggerFactory via Startup.Configure:

namespace OpenIdConnectSample
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .ConfigureLogging(options => options.AddDebug(LogLevel.Information))
                .Build();

            host.Run();
        }
    }
}
sayedihashimi commented 8 years ago

@DamianEdwards @davidfowl thoughts?

davidfowl commented 8 years ago

Not sure about this, I thought about it as well but if you configure logging based on the configuration system we'll end up reading appsettings.json in the Program.Main which I'm not a fan of. Ideally host configuration and Startup configuration would remain separate.