Share via

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

Amit Singh Rawat 731 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.

Developer technologies | ASP.NET Core | Other
0 comments No comments

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 84,061 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

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.