logging-observability

Implements structured logging, correlation IDs, health checks, and OpenTelemetry tracing in ASP.NET Core applications.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill logging-observability-agibuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: logging-observability
Source: https://github.com/AGIBuild/dotnet.CI.template/tree/main/.cursor/skills/logging-observability
Command: npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill logging-observability-agibuild

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? ASP.NET Core applications without structured logging and observability are difficult to debug in production, making it hard to trace requests across services, diagnose failures, and monitor system health. ## Core Features & Use Cases - Structured Logging with Serilog: Configure bootstrap loggers, JSON-formatted output, contextual enrichment, and external sinks like Seq for centralized log aggregation. - Correlation IDs & Request Tracing: Add middleware that assigns every request a unique correlation ID and enriches logs with user, path, and timing context for end-to-end tracing. - Health Checks & OpenTelemetry: Implement database and external service health checks with JSON responses, plus distributed tracing and metrics via OpenTelemetry instrumentation. - Use Case: When deploying a Razor Pages application to production, use this Skill to set up Serilog with correlation IDs, add health check endpoints for your database and Redis cache, and wire OpenTelemetry tracing so you can diagnose a slow order-processing request across services. ## Quick Start Set up Serilog structured logging with correlation ID middleware and health checks in my ASP.NET Core Razor Pages application.

Frequently Asked Questions about logging-observability

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Serilog in an ASP.NET Core application?▼

Install Serilog.AspNetCore, create a bootstrap logger before building the host, then register it via services.AddSerilog with configuration from appsettings.json. Enrich logs with machine name and context, and write to sinks like Console or Seq.

How to add correlation IDs to ASP.NET Core request logs?▼

Create middleware that reads or generates an X-Correlation-Id header, adds it to the response headers, and pushes it into Serilog's LogContext. Register the middleware early in the pipeline so all downstream logs include the correlation ID.

What is the LoggerMessage pattern in .NET logging?▼

LoggerMessage is a compile-time source generator that creates high-performance logging methods, avoiding string interpolation overhead and boxing. Define partial methods with the LoggerMessage attribute specifying EventId, level, and message template.

Does OpenTelemetry work with ASP.NET Core health checks?▼

OpenTelemetry and health checks are complementary but separate. OpenTelemetry provides distributed tracing and metrics via instrumentation libraries, while health checks expose endpoint status for load balancers and monitoring systems.

Why should I avoid string interpolation in log messages?▼

String interpolation evaluates even when the log level is disabled, wasting resources, and destroys structured data. Use message templates with named parameters so values are captured as searchable structured properties.

How do I log slow MediatR requests in .NET?▼

Implement an IPipelineBehavior that wraps handler execution with a Stopwatch, logging a warning when elapsed time exceeds a threshold such as 500ms. Register the behavior in the MediatR configuration during service setup.