liveBook · Manning

Log

As explained in Pro ASP.NET Core 7, Tenth Edition

The practice of recording informational, diagnostic, warning, and error messages generated by software.

ASP.NET Core logging records application state to help track errors, monitor performance, and diagnose problems. Logging providers forward messages to destinations where they can be viewed, stored, or processed; built-in options include console, debug, and EventSource providers. section 15.3

Use ILogger<T> to assign messages a category, conventionally the class that generates them. Messages carry severity levels from Trace through Critical; use app.Logger for logging in Program.cs. section 15.3.1

Table 15.4 The ILogger<T> extension methods (view table figure)

Name

Description

LogTrace

This method generates a Trace-level message, used for low-level debugging during development.

LogDebug

This method generates a Debug-level message, used for low-level debugging during development or production problem resolution.

LogInformation

This method generates an Information-level message, used to provide information about the general state of the application.

LogWarning

This method generates a Warning-level message, used to record unexpected, but minor, problems that are unlikely to disrupt the application.

LogError

This method generates an Error-level message, used to record exceptions or errors that are not handled by the application.

LogCritical

This method generates a Critical-level message, used to record serious failures.

Compare the six severity levels and the kinds of messages each is intended to record. section 15.3.1

Logging a request

A population endpoint uses ILogger<Population> to log when request processing starts and finishes. Requesting /population makes the Debug messages visible in console output. section 15.3.1

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Works through providers, categories, severity levels, class and Program.cs logging, and console verification.
Examples
Logs request start and completion for a population endpoint and startup pipeline configuration.
What you can do after
Apply it via ILogger<T> or app.Logger to emit categorized, leveled messages and verify them in console output.
How it connects
Connects ILogger<T> and logging providers to ASP.NET Core request handling.

Also explained in

Compare how 14 books explain log →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.