Logging evolution in .NET
Logs are the most flexible telemetry signal and usually include a timestamp, a level, a category, a message, and sometimes attributes.
Logs are frequently intended to be human-readable and don’t have a strict structure. Here’s an example of a log record written to stdout
by an ASP.NET Core application:
info: Microsoft.Hosting.Lifetime[14] Now listening on: http://localhost:5050
If we need to investigate something, we’d first look for logs describing interesting operations and then read the filtered logs. Our ability to understand what happened depends on how much context is logged and how searchable it is, with tools such as grep
.
Structured logs are sometimes called events. Events are intended to be queried, potentially across multiple requests and based on any property, and need a strict and consistent structure. Here’s the previous log record in the OpenTelemetry JSON format:
...