Claude-code-skills ln-771-logging-configurator
Configures structured JSON logging with Serilog (.NET) or structlog (Python). Use when adding logging to backend projects.
git clone https://github.com/levnikolaevich/claude-code-skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/levnikolaevich/claude-code-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills-catalog/ln-771-logging-configurator" ~/.claude/skills/levnikolaevich-claude-code-skills-ln-771-logging-configurator && rm -rf "$T"
skills-catalog/ln-771-logging-configurator/SKILL.mdln-771-logging-configurator
Type: L3 Worker Category: 7XX Project Bootstrap
Configures structured JSON logging for .NET and Python projects.
Overview
| Aspect | Details |
|---|---|
| Input | Context Store from ln-770 |
| Output | Logging configuration files |
| Stacks | .NET (Serilog), Python (structlog) |
Phase 1: Receive Context
Accept Context Store from coordinator.
Required Context:
: .NET or PythonSTACK
: ASP.NET Core or FastAPIFRAMEWORK
: Version numberFRAMEWORK_VERSION
: Project directory pathPROJECT_ROOT
: Development or ProductionENVIRONMENT
Validation:
- If
not provided, detect from project filesSTACK - If version not provided, use latest stable
Phase 2: Research Current Best Practices
Use MCP tools to get up-to-date documentation.
For .NET (Serilog):
MCP ref: "Serilog ASP.NET Core structured logging configuration" Context7: /serilog/serilog-aspnetcore
For Python (structlog):
MCP ref: "structlog Python structured logging configuration" Context7: /hynek/structlog
Key Patterns to Research:
- Request logging middleware
- Log enrichment (correlation ID, user context)
- Log level configuration by environment
- Sink configuration (Console, File, Seq, Elastic)
Phase 3: Decision Points
Ask user for configuration preferences.
Q1: Log Format
| Option | When to Use |
|---|---|
| JSON (Recommended for Production) | Machine-readable, log aggregation systems |
| Pretty/Colored (Recommended for Development) | Human-readable, local debugging |
Q2: Enrichment Fields
| Field | Description | Default |
|---|---|---|
| Request tracking across services | ✓ Yes |
| Authenticated user identifier | ✓ Yes |
| HTTP request path | ✓ Yes |
| Request duration in ms | ✓ Yes |
| Server hostname | Optional |
| Thread identifier | Optional |
Q3: Log Sinks
| Sink | Use Case |
|---|---|
| Console | Always enabled |
| File | Local persistence, log rotation |
| Seq | Structured log server |
| Elasticsearch | Log aggregation at scale |
Q4: Log Levels by Environment
| Level | Development | Production |
|---|---|---|
| Default | Debug | Information |
| Microsoft.* | Information | Warning |
| System.* | Information | Warning |
| Application | Debug | Information |
Phase 4: Generate Configuration
Generate files based on stack and decisions.
.NET Output Files
| File | Purpose |
|---|---|
| Service registration |
(update) | Serilog configuration |
(update) | Dev overrides |
Generation Process:
- Use MCP ref to get current Serilog API
- Generate LoggingExtensions.cs with:
- UseSerilog configuration
- Request logging middleware
- Enrichment configuration
- Update appsettings.json with Serilog section
Packages to Add:
Serilog.AspNetCoreSerilog.Sinks.Console
(if File sink selected)Serilog.Sinks.File
(if machineName selected)Serilog.Enrichers.Environment
Python Output Files
| File | Purpose |
|---|---|
| structlog configuration |
| Request logging |
Generation Process:
- Use MCP ref to get current structlog API
- Generate logging_config.py with:
- Processor chain configuration
- Renderer selection (JSON/Console)
- Log level configuration
- Generate logging_middleware.py for FastAPI
Packages to Add:
structlog
(if JSON format)python-json-logger
Phase 5: Validate
Verify the configuration works.
Validation Steps:
-
Check imports: Ensure all packages are available
- .NET:
dotnet list package | grep Serilog - Python:
pip list | grep structlog
- .NET:
-
Syntax check:
- .NET:
dotnet build --no-restore - Python:
python -m py_compile core/logging_config.py
- .NET:
-
Test log output:
- Start application
- Make test request
- Verify log format matches configuration
Expected Log Format:
{ "timestamp": "2026-01-10T12:00:00.000Z", "level": "info", "message": "Request completed", "correlationId": "abc-123", "requestPath": "/api/health", "responseTime": 45, "statusCode": 200 }
Return to Coordinator
Return result to ln-770:
{ "status": "success", "files_created": [ "Extensions/LoggingExtensions.cs", "appsettings.json" ], "packages_added": [ "Serilog.AspNetCore", "Serilog.Sinks.Console" ], "registration_code": "services.AddLoggingServices(configuration);", "message": "Configured structured logging with Serilog" }
Idempotency
This skill is idempotent:
- Phase 1: Check if logging already configured (Grep for Serilog/structlog)
- If configured: Return
{ "status": "skipped", "message": "Logging already configured" } - If not: Proceed with configuration
Reference Links
Critical Rules
- Use MCP ref/Context7 for current API — do not hardcode Serilog/structlog config from memory
- Idempotent — if Serilog or structlog already configured, return
immediatelystatus: "skipped" - Environment-aware log levels — Debug for Development, Information for Production (never Warning default)
- Always include correlation ID enrichment — required for distributed tracing
- Return structured response —
,files_created
,packages_added
for coordinator aggregationregistration_code
Definition of Done
- Context Store received and validated (stack, framework, version)
- Best practices researched via MCP tools for target stack
- User decisions collected (format, enrichment, sinks, log levels)
- Configuration files generated (extensions/config + appsettings or Python modules)
- Syntax validated (
ordotnet build
)py_compile - Structured JSON response returned to ln-770 coordinator
Version: 2.0.0 Last Updated: 2026-01-10