How "WebApplication.CreateBuilder()" method configures default logging Providers.

ASR 671 Reputation points
2023-05-02T09:01:55.9766667+00:00

How the "WebApplication.CreateBuilder()" method configures logging.

In ASP.NETCORE GitHub page "https://github.com/dotnet/aspnetcore/blob/main/src/DefaultBuilder/src".

I can see the "ConfigureLogging" code is only enabled within WebHost.CreateDefaultBuilder() method.

But I am calling ""WebApplication.CreateBuilder()" and it returns "WebApplicationBuilder" object.

And even in WebApplicationBuilder class I am not able to find where these logging providers called.

Can anyone explain the flow how "WebApplication.CreateBuilder()" method configures default logging Providers.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,207 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,931 Reputation points
    2023-05-02T17:18:45.5533333+00:00

    see line 256:

    https://github.com/dotnet/aspnetcore/blob/main/src/DefaultBuilder/src/WebApplicationBuilder.cs#L256

    it configures and adds logging as a service. many components are configured to call logging if the service is configured.

    note the default logger is the console logger

    0 comments No comments