serilog

Configure Serilog structured logging in ASP.NET Core with sinks and enrichment.

1|Updated Apr 28, 2026
One-click install
npx skills add https://github.com/Trossitec/dotnet-claude-kit --skill serilog-trossitec
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: serilog
Source: https://github.com/Trossitec/dotnet-claude-kit/tree/main/skills/serilog
Command: npx skills add https://github.com/Trossitec/dotnet-claude-kit --skill serilog-trossitec

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Serilog skill helps you configure reliable, structured logging so your .NET apps produce queryable events instead of noisy, unstructured strings that are hard to troubleshoot in production.

Core Features & Use Cases

  • Two-stage initialization to capture startup failures with a bootstrap logger, then switch to the full configured logger once DI is ready.
  • Structured logging with message templates and enrichment using LogContext, environment/machine enrichers, and request diagnostics for correlation.
  • Configurable sinks, destructuring, and filtering via appsettings.json and Serilog.Expressions so you can route and control logs per environment (console, rolling files, Seq, OTLP).

Quick Start

Configure Serilog in your ASP.NET Core app using AddSerilog with appsettings.json, add Serilog request logging, and ensure logs use message templates with structured properties and safe destructuring limits.

Frequently Asked Questions about serilog

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

FAQPage Schema
How do I configure structured logging in ASP.NET Core using Serilog?

You configure structured logging in ASP.NET Core using Serilog by calling AddSerilog, defining sinks in appsettings.json, and using message templates with LogContext enrichment so startup and application events become queryable.

Why do I need two-stage bootstrap initialization for Serilog?

Two-stage bootstrap initialization for Serilog is needed to capture startup failures with a bootstrap logger before switching to the fully configured logger once dependency injection is ready, preventing the loss of early diagnostic events.

Should I use AddSerilog or UseSerilog when integrating Serilog into ASP.NET Core?

Prefer AddSerilog over UseSerilog when integrating Serilog into ASP.NET Core to ensure better compatibility with the host builder pipeline and proper dependency injection lifecycle management for structured logging.

Can I route logs to different sinks like Console, File, and Seq based on environment?

Yes, you can route logs to sinks like Console, File, Seq, and OpenTelemetry by configuring them within appsettings.json and applying Serilog.Expressions filtering to control log output per environment.

How do I add request logging and correlation enrichers in Serilog?

Add request logging and correlation enrichers in Serilog by implementing request diagnostics enrichment and pushing properties to LogContext, ensuring logs include environment details and machine information for traceable request correlation.

What are the limitations of destructuring limits in Serilog message templates?

Destructuring limits in Serilog message templates prevent excessive memory usage by limiting object serialization depth and length, ensuring complex objects logged during application events do not overwhelm sinks or degrade performance.