ASP.NET Core’s logging service records messages about application state, errors, performance, and diagnostic problems. Logging providers forward those messages to destinations where they can be viewed or processed. Console, debug, and EventSource providers are enabled by default; the console provider makes messages visible without additional configuration. section 15.3
In an endpoint or other class, request an ILogger<T> and use the class as T. That type becomes the message category: ILogger<Population> assigns messages to Platform.Population. For example, logger.LogDebug("Started processing for {path}", context.Request.Path) records a request-path message at Debug level. The logging methods range from LogTrace for detailed diagnostics to LogCritical for serious failures, with overloads for strings and exceptions. section 15.3.1
Check the endpoint log
Map GET population/{city?} to Population.Endpoint, then request http://localhost:5000/population. The console output includes Debug messages for the start and completion of processing, labeled with the Platform.Population category. section 15.3.1
Top-level statements in Program.cs do not have a class suitable for ILogger<T>. Use app.Logger for straightforward pipeline-configuration messages. If those messages need a specific category, obtain ILoggerFactory from app.Services and call CreateLogger("Pipeline"). section 15.3.1
Control what appears through Logging:LogLevel in appsettings.json or appsettings.Development.json. Messages below a category’s minimum level are discarded. A setting can match a full category such as Platform.Population or a broader namespace; unmatched categories use Default. Development settings can allow Debug messages while keeping System and Microsoft at Information. Set a category to None to disable its messages. section 15.3.3
Listing 15.24 Configuring the appsettings.Development.json file in the Platform folder
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information",
"Microsoft.AspNetCore": "Warning",
"Microsoft.AspNetCore.Routing": "Debug"
}
}
}
This configuration keeps general ASP.NET Core logging at Warning while allowing Debug messages specifically from Microsoft.AspNetCore.Routing. section 15.3.3

