Skip to content

ConfigureLogging(Action<ILoggerFactory>) removed from IWebHostBuilder #241

Open
@JunTaoLuo

Description

@JunTaoLuo

ConfigureLogging(Action<ILoggerFactory>) has been removed from the IWebHostBuilder interface in aspnet/Hosting#1007.

The recommendation is to use the overload of ConfigureLogging that takes in a concrete type of ILoggerFactory with the signature ConfigureLogging<T>(Action<WebHostBuilderContext, T>) where T : ILoggerFactory added in aspnet/Hosting#955. For example:

var host = new WebHostBuilder()
    .UseLoggerFactory(new CustomLoggerFactory())
    .ConfigureLogging<CustomLoggerFactory>((hostingContext, factory) => 
    {
         factory.UseConfiguration(hostingContext.Configuration.GetSection("Logging"));
         factory.AddConsole();
    })
...

An alternative would be to use the newly added extension ConfigureLogging(Action<LoggerFactory>) to configure the default LoggerFactory implementation, for example:

var host = new WebHostBuilder()
    .ConfigureLogging(factory => factory.AddConsole())
...

See aspnet/Hosting#1069 for discussion

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions