liveBook · Manning

Log entry

As explained in Building Web APIs with ASP.NET Core

A log event is a recorded diagnostic event containing information such as a category, severity level, message, and associated metadata.

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

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Defines entry fields, demonstrates creation, and contrasts unstructured with structured storage without implementing a provider’s storage internals.
Examples
Uses BoardGamesController.Get, LogInformation, SwaggerUI, and Visual Studio’s Output window to demonstrate a recorded entry.
What you can do after
Apply it via ILogger to record controller events, select severity levels, and verify emitted entries in the development output.
How it connects
Connects logging with ILogger, LogLevel, structured logging, unstructured logging, monitoring systems, and storage providers.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.