liveBook · Manning

Event id

As explained in ASP.NET Core in Action, 3e

EventId is a .NET logging value that identifies a category or kind of log event.

An EventId is an optional integer attached to a log entry. It helps you quickly find related events; when omitted, its value is 0. section 26.2

Choose distinct identifiers for recurring application events:

  • Use 1000 when a user loads a recipe that does not exist. section 26.2
  • Use 1001 when a user tries to access a recipe without permission. section 26.2

Event ID with generated logging

A LoggerMessage declaration can assign event ID 10 to an information-level message: [LoggerMessage(10, LogLevel.Information, "Loaded {RecipeCount} recipes")]. Calling the generated method records the event with that identifier.

How ASP.NET Core in Action, 3e covers it

How deep it goes
Defines optional integer identifiers, examples, and the zero default, then demonstrates assignment through LoggerMessage.
Examples
Uses missing-recipe, unauthorized-recipe, and loaded-recipes events with identifiers 1000, 1001, and 10.
What you can do after
Diagnose/debug with it by grouping related log entries under consistent integer identifiers.
How it connects
Connects EventId with ILogger, log levels, structured logging placeholders, and source-generated logging.

Also explained in

Compare how 2 books explain event id →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.