serilog

Implement Serilog structured logging in .NET with two-stage bootstrap and DI configuration.

Updated Apr 27, 2026
One-click install
npx skills add https://github.com/shahdanish/vibepos --skill serilog-shahdanish
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: serilog
Source: https://github.com/shahdanish/vibepos/tree/main/skills/serilog
Command: npx skills add https://github.com/shahdanish/vibepos --skill serilog-shahdanish

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you implement reliable, structured logging in .NET so startup errors are captured, log data is consistent, and events are easy to search and analyze across environments.

Core Features & Use Cases

  • Two-stage initialization: Capture early startup failures with a bootstrap logger, then switch to the full DI-and-configuration logger once services are ready.
  • Structured message templates: Use property-based logging (for example, {OrderId}) instead of string interpolation so logs stay queryable and efficient.
  • Config-driven sinks and enrichers: Centralize minimum levels, overrides, enrichers, and sinks in appsettings.json for environment-specific behavior without redeployments.
  • Request logging and contextual enrichment: Enable HTTP request logging and attach diagnostic context (such as host, user agent, user id) to each request.
  • Destructuring controls: Apply limits for depth, string length, and collection counts to prevent runaway payloads and memory-heavy logs.

Use case example: When deploying a .NET 9+ service, you want console output during development, file/rolling logs for auditing, and queryable request logs in Seq for production—without losing startup errors.

Quick Start

Load the serilog Skill and configure logging by adding the provided two-stage bootstrap logger pattern and appsettings.json Serilog configuration to your .NET application so startup, structured events, and request logging are enabled.

Frequently Asked Questions about serilog

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

FAQPage Schema
How do I add structured logging in .NET using Serilog?

Add structured logging in .NET using Serilog by implementing a two-stage bootstrap logger for startup diagnostics, then transitioning to full DI and appsettings.json integration for consistent, queryable event data across your application lifecycle.

Why use message templates instead of string interpolation for .NET logging?

Message templates use property-based logging like {OrderId} instead of string interpolation, keeping your .NET logs queryable and efficient. This structured format allows log sinks to index specific properties, making events easy to search and analyze across environments.

How do I capture .NET startup errors before dependency injection is ready?

Capture .NET startup errors before dependency injection is ready by configuring a two-stage bootstrap logger. This initial logger records early startup failures, then switches to the full config-driven logger once services are registered and application configuration is loaded.

Can I configure Serilog sinks and log levels in appsettings.json?

Yes, you can configure Serilog sinks and log levels in appsettings.json. Centralize MinimumLevel settings, WriteTo sink configurations, overrides, and Enrich settings there to manage environment-specific logging behavior without requiring application redeployments.

What's the best way to prevent large log payloads in .NET applications?

Prevent large log payloads in .NET applications by applying destructuring controls during log configuration. Set strict limits for object depth, string length, and collection counts to avoid runaway memory-heavy logs and ensure safer log payloads.

How do I add HTTP request logging and diagnostic context in ASP.NET Core?

Add HTTP request logging and diagnostic context in ASP.NET Core by enabling request logging features and attaching LogContext enrichment. This injects diagnostic properties like host, user agent, and user id into every request log for better traceability.