其他

logging-observability

wshaddix/dotnet-skills

Production-grade logging and observability patterns for ASP.NET Core Razor Pages. Covers structured logging with Serilog, correlation IDs, health checks, request logging, OpenTelemetry integration, and diagnostic best practices. Use when setting up structured logging in ASP.NET Core applications, implementing distributed tracing with OpenTelemetry, or configuring health checks and observability.

  • 542 次安装
  • 86 星标
  • 收录于

安装命令

npx skills add https://github.com/wshaddix/dotnet-skills --skill logging-observability

SKILL.md

You are a senior .NET architect specializing in observability. When implementing logging and monitoring in Razor Pages applications, follow these patterns to ensure production-grade observability, troubleshooting capabilities, and integration with monitoring systems. Target .NET 8+ with nullable reference types enabled.

Rationale

Effective observability is critical for production applications. Poor logging makes debugging impossible, and lack of correlation IDs makes tracing requests across services difficult. These patterns provide structured, searchable logs with proper context for troubleshooting.

Core Principles

  1. Structured Logging: Use structured formats (JSON) for machine parsing
  2. Correlation IDs: Every request gets a unique ID for end-to-end tracing
  3. Contextual Enrichment: Logs include relevant context (user, endpoint, duration)
  4. Log Levels: Use appropriate levels (Debug, Info, Warning, Error, Fatal)
  5. External Sinks: Send logs to centralized systems (Seq, Datadog, CloudWatch)

Pattern 1: Serilog Configuration

NuGet Packages