ln-771-logging-configurator

Configures structured JSON logging with Serilog (.NET) or structlog (Python). Use when adding logging to backend projects.

310 stars

Best use case

ln-771-logging-configurator is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Configures structured JSON logging with Serilog (.NET) or structlog (Python). Use when adding logging to backend projects.

Teams using ln-771-logging-configurator should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/ln-771-logging-configurator/SKILL.md --create-dirs "https://raw.githubusercontent.com/levnikolaevich/claude-code-skills/main/skills-catalog/ln-771-logging-configurator/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/ln-771-logging-configurator/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How ln-771-logging-configurator Compares

Feature / Agentln-771-logging-configuratorStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Configures structured JSON logging with Serilog (.NET) or structlog (Python). Use when adding logging to backend projects.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# ln-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:**
- `STACK`: .NET or Python
- `FRAMEWORK`: ASP.NET Core or FastAPI
- `FRAMEWORK_VERSION`: Version number
- `PROJECT_ROOT`: Project directory path
- `ENVIRONMENT`: Development or Production

**Validation:**
- If `STACK` not provided, detect from project files
- 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:**
1. Request logging middleware
2. Log enrichment (correlation ID, user context)
3. Log level configuration by environment
4. 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 |
|-------|-------------|---------|
| `correlationId` | Request tracking across services | ✓ Yes |
| `userId` | Authenticated user identifier | ✓ Yes |
| `requestPath` | HTTP request path | ✓ Yes |
| `responseTime` | Request duration in ms | ✓ Yes |
| `machineName` | Server hostname | Optional |
| `threadId` | 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 |
|------|---------|
| `Extensions/LoggingExtensions.cs` | Service registration |
| `appsettings.json` (update) | Serilog configuration |
| `appsettings.Development.json` (update) | Dev overrides |

**Generation Process:**
1. Use MCP ref to get current Serilog API
2. Generate LoggingExtensions.cs with:
   - UseSerilog configuration
   - Request logging middleware
   - Enrichment configuration
3. Update appsettings.json with Serilog section

**Packages to Add:**
- `Serilog.AspNetCore`
- `Serilog.Sinks.Console`
- `Serilog.Sinks.File` (if File sink selected)
- `Serilog.Enrichers.Environment` (if machineName selected)

### Python Output Files

| File | Purpose |
|------|---------|
| `core/logging_config.py` | structlog configuration |
| `middleware/logging_middleware.py` | Request logging |

**Generation Process:**
1. Use MCP ref to get current structlog API
2. Generate logging_config.py with:
   - Processor chain configuration
   - Renderer selection (JSON/Console)
   - Log level configuration
3. Generate logging_middleware.py for FastAPI

**Packages to Add:**
- `structlog`
- `python-json-logger` (if JSON format)

---

## Phase 5: Validate

Verify the configuration works.

**Validation Steps:**

1. **Check imports:** Ensure all packages are available
   - .NET: `dotnet list package | grep Serilog`
   - Python: `pip list | grep structlog`

2. **Syntax check:**
   - .NET: `dotnet build --no-restore`
   - Python: `python -m py_compile core/logging_config.py`

3. **Test log output:**
   - Start application
   - Make test request
   - Verify log format matches configuration

**Expected Log Format:**
```json
{
  "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:

```json
{
  "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

- [Serilog.AspNetCore](https://github.com/serilog/serilog-aspnetcore)
- [structlog Documentation](https://www.structlog.org/)
- [ASP.NET Core Logging](https://learn.microsoft.com/aspnet/core/fundamentals/logging/)

---

## 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 `status: "skipped"` immediately
- **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`, `registration_code` for coordinator aggregation

## 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 (`dotnet build` or `py_compile`)
- [ ] Structured JSON response returned to ln-770 coordinator

---

**Version:** 2.0.0
**Last Updated:** 2026-01-10

Related Skills

ln-773-cors-configurator

310
from levnikolaevich/claude-code-skills

Configures CORS policy for development and production environments. Use when setting up cross-origin access for APIs.

ln-741-linter-configurator

310
from levnikolaevich/claude-code-skills

Configures ESLint, Prettier, Ruff, mypy, and .NET analyzers. Use when setting up linting and formatting for a project.

ln-733-env-configurator

310
from levnikolaevich/claude-code-skills

Configures environment variables and secrets protection. Use when setting up .env files and gitignore rules for a project.

ln-012-mcp-configurator

310
from levnikolaevich/claude-code-skills

Installs MCP packages, registers servers in Claude Code, configures hooks, permissions, and migrations. Use when MCP needs setup or reconfiguration.

ln-914-community-responder

310
from levnikolaevich/claude-code-skills

Responds to unanswered GitHub discussions and issues with codebase-informed replies. Use when clearing community question backlog.

ln-913-community-debater

310
from levnikolaevich/claude-code-skills

Launches RFC and debate discussions on GitHub. Use when proposing changes that need community input or voting.

ln-912-community-announcer

310
from levnikolaevich/claude-code-skills

Composes and publishes announcements to GitHub Discussions. Use when sharing releases, updates, or news with the community.

ln-911-github-triager

310
from levnikolaevich/claude-code-skills

Produces prioritized triage report from open GitHub issues, PRs, and discussions. Use when reviewing community backlog.

ln-910-community-engagement

310
from levnikolaevich/claude-code-skills

Analyzes community health and delegates engagement tasks. Use when managing GitHub issues, discussions, and announcements.

ln-840-benchmark-compare

310
from levnikolaevich/claude-code-skills

Runs built-in vs hex-line benchmark with scenario manifests, activation checks, and diff-based correctness. Use when measuring hex-line MCP performance against built-in tools.

ln-832-bundle-optimizer

310
from levnikolaevich/claude-code-skills

Reduces JS/TS bundle size via tree-shaking, code splitting, and unused dependency removal. Use when optimizing frontend bundle size.

ln-831-oss-replacer

310
from levnikolaevich/claude-code-skills

Replaces custom modules with OSS packages using atomic keep/discard testing. Use when migrating custom code to established libraries.