A log entry is a timestamped record of an application event and its context. It commonly includes a category, severity level, message, and associated metadata. section 7.2.1 section 7.0
In an ASP.NET Core API, ILogger creates entries from controller code and shared middleware. LogInformation is a convenient method, while Log supports an explicitly selected LogLevel. section 7.2.1
A log entry can be handled in several formats and destinations:
- Unstructured entries appear as raw text, which is convenient for display but requires parsing for automated processing. section 7.3
- Structured entries use predefined fields, enabling field queries, aggregation, format conversion, indexing, and storage in databases or external repositories. section 7.3.2
Verify a controller entry
Add _logger.LogInformation("Get method started.") to BoardGamesController.Get, run the API in Debug mode, call the endpoint through SwaggerUI, and inspect Visual Studio’s Output window for the controller category, Information level, and message. section 7.2.1
public async Task<RestDTO<BoardGame[]>> Get(
[FromQuery] RequestDTO<BoardGameDTO> input)
{
_logger.LogInformation("Get method started."); #1
// ... rest of code omitted
Shows the controller call that creates a log entry with ILogger and LogInformation. section 7.2.1
