
Var logger = LoggerFactory.Create(config => The following example calls AddConsole in Program.cs and logs the /Test endpoint: var builder = WebApplication.CreateBuilder(args)

The following example calls in Program.cs and logs informational messages: var builder = WebApplication.CreateBuilder(args) Īpp.Logger.LogInformation("Adding Routes") Īpp.Logger.LogInformation("Starting the app") Each provider defines an alias that can be used in configuration in place of the fully qualified type name. For example, the level in overrides the level in LogLevel.Default. _logger.LogInformation("About page visited at placeholder is the provider name. The Log level indicates the severity of the logged event.

The following code overrides the default set of logging providers added by WebApplication.CreateBuilder: var builder = WebApplication.CreateBuilder(args) Īlternatively, the preceding logging code can be written as follows: var builder = WebApplication.CreateBuilder() The next several sections provide samples based on the ASP.NET Core web app templates, which use the Generic Host. The preceding code shows the Program.cs file created with the ASP.NET Core web app templates. Var builder = WebApplication.CreateBuilder(args)

For more information on logging in Blazor apps, see ASP.NET Core Blazor logging. By Kirk Larkin, Juergen Gutsch, and Rick Anderson
