Skip to content
Skills Library
Programming · Building & coding

serilog-logging-setup

/serilog-logging-setup

Set up structured logging with Serilog in ASP.NET Core — JSON output, enrichers, request logging, log levels, and sinks — correlated with traces. Use this skill whenever the user wants Serilog, structured logging, JSON logs, request logging, log enrichment, log sinks (Seq/Elastic/console), or asks "how do I add logging / set up Serilog / get structured logs". Always use this skill for Serilog/structured-logging requests; it wires production-shaped logging, not just Console.WriteLine.

Licence
MIT
Last repository change
09.08.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 09.08.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Set up structured logging with Serilog in ASP.NET Core — JSON output, enrichers, request logging, log levels, and sinks — correlated with traces. Use this skill whenever the user wants Serilog, structured logging, JSON logs, request logging, log enrichment, log sinks (Seq/Elastic/console), or asks "how do I add logging / set up Serilog / get structured logs". Always use this skill for Serilog/structured-logging requests; it wires production-shaped logging, not just Console.WriteLine.

Triggers from the description

how do I add logging / set up Serilog / get structured logs
Original author description

Set up structured logging with Serilog in ASP.NET Core — JSON output, enrichers, request logging, log levels, and sinks — correlated with traces. Use this skill whenever the user wants Serilog, structured logging, JSON logs, request logging, log enrichment, log sinks (Seq/Elastic/console), or asks "how do I add logging / set up Serilog / get structured logs". Always use this skill for Serilog/structured-logging requests; it wires production-shaped logging, not just Console.WriteLine.

How it works

  1. Input — point it at your project
  2. Packages + wiring
  3. Structured logging done right
  4. What to set
  5. Principles
  6. How to use it & best prompts
Original SKILL.md headings · 49 lines, 289 words
SKILL.md preview
---
name: serilog-logging-setup
description: Set up structured logging with Serilog in ASP.NET Core — JSON output, enrichers, request logging, log levels, and sinks — correlated with traces. Use this skill whenever the user wants Serilog, structured logging, JSON logs, request logging, log enrichment, log sinks (Seq/Elastic/console), or asks "how do I add logging / set up Serilog / get structured logs". Always use this skill for Serilog/structured-logging requests; it wires production-shaped logging, not just Console.WriteLine.
category: Observability
version: 1.0.0
---

# Serilog Structured Logging Setup

Wire up Serilog in ASP.NET Core for structured (JSON) logs with enrichers, request logging, sensible levels, and sinks — correlated with your traces.

## Input — point it at your project
Works on a target: a **project** or **GitHub URL**. Inspect current logging: `grep -rn "UseSerilog\|ILogger\|Log.Logger\|AddSerilog" --include=*.cs <target>`. If OTel is present, wire log/trace correlation.

## Packages + wiring
```
dotnet add package Serilog.AspNetCore
dotnet add package Serilog.Sinks.Seq        # or Console/Elastic/etc.
```
```csharp
builder.Host.UseSerilog((ctx, services, lc) => lc
    .ReadFrom.Configuration(ctx.Configuration)
    .ReadFrom.Services(services)
    .Enrich.FromLogContext()
    .Enrich.WithMachineName()
    .Enrich.WithProperty("service", "orders")
    .WriteTo.Console(new RenderedCompactJsonFormatter())   // structured JSON
    .WriteTo.Seq(ctx.Configuration["Seq:Url"]!));

app.UseSerilogRequestLogging();   // one tidy log line per request instead of the default noise
```

## Structured logging done right
```csharp
// GOOD: message template + properties (queryable)
logger.LogInformation("Order {OrderId} placed by {CustomerId} for {Total}", id, customerId, total);
// BAD: interpolated string (loses structure)
logger.LogInformation($"Order {id} placed");
```

## What to set
- **Levels** — `Information` default, `Warning` for noisy frameworks, `Debug` only in dev. Configure via `appsettings`.
- **Enrichers** — machine, environment, and a correlation/trace id (see `correlation-id-middleware`).
- **Request logging** — `UseSerilogRequestLogging` for one structured line per request with status + duration.
- **Trace correlation** — include `TraceId`/`SpanId` so logs link to traces.

## Principles
- **Message templates, not interpolation** — structure is the whole point of structured logging.
- **Don't log secrets/PII.** Be deliberate about what goes into properties.
- Log at the right level; `Information` for business events, `Error` with the exception object (not `ex.Message`).
- One sink for local (console JSON), one for aggregation (Seq/Elastic/Loki).

## How to use it & best prompts
"Set up Serilog with JSON logs and Seq", "add request logging", "correlate my logs with traces", "fix my logging to be structured". Pairs with `opentelemetry-setup` and `correlation-id-middleware`.
Files in this package (2)
  • SKILL.md 3 KB
  • USAGE.md 1 KB

Versions

The database has no other skills named serilog-logging-setup.

Database snapshot: 13.11.2026 · package version 3bb45f1f9ddd (SHA-256 digest of the entire package)

Downloads in the last 30 days: 3 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100serilog
    Use when adding structured logging to .NET apps — Serilog.AspNetCore UseSerilogRequestLogging, LoggerConfiguration WriteTo.Console/File, appsettings.json ReadFrom.Configuration, DI via builder.Services.AddSerilog(), or diagnosing missing log output, duplicate ASP.NET Core…
  • 100serilog
    Structured logging with Serilog for .NET 10 applications. Covers two-stage bootstrap, appsettings configuration, enrichers, sinks, request logging, destructuring, and Serilog.Expressions. Load this skill when setting up Serilog, configuring log sinks, enrichers, or structured…
  • 100serilog
    Guidance for Serilog structured logging library in .NET. USE FOR: Serilog sink configuration, structured event logging, log enrichment, ASP.NET Core request logging, Serilog expressions and filtering, Seq/Elasticsearch/Application Insights integration. DO NOT USE FOR:…
  • 100nlog
    Guidance for NLog logging framework in .NET. USE FOR: NLog target configuration, layout renderers, structured logging with NLog, async logging, conditional routing, custom targets, NLog integration with ASP.NET Core. DO NOT USE FOR: Microsoft.Extensions.Logging abstractions (use…
  • 100orchardcore-logging-serilog
    Skill for configuring Serilog logging in Orchard Core. Covers the OrchardCore.Logging.Serilog package reference in the web project, appsettings.json Serilog configuration with Console and File sinks, Program.cs initialization with UseSerilog or UseSerilogWeb, tenant-aware…
  • 100logging
    Observability overview and glue for .NET 10: how the pieces fit together, plus the cross-cutting parts owned here — ASP.NET health check endpoints (/health), correlation IDs, and log-level strategy. For deep Serilog setup load `serilog`; for traces and metrics load…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.