ln-771-logging-configurator by levnikolaevich/claude-code-skills
npx skills add https://github.com/levnikolaevich/claude-code-skills --skill ln-771-logging-configurator类型: L3 工作者 类别: 7XX 项目引导 父级: ln-770-crosscutting-setup
为 .NET 和 Python 项目配置结构化 JSON 日志记录。
| 方面 | 详情 |
|---|---|
| 输入 | 来自 ln-770 的上下文存储 |
| 输出 | 日志记录配置文件 |
| 技术栈 | .NET (Serilog), Python (structlog) |
接受来自协调器的上下文存储。
所需上下文:
STACK: .NET 或 PythonFRAMEWORK: ASP.NET Core 或 FastAPIFRAMEWORK_VERSION: 版本号广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
PROJECT_ROOT: 项目目录路径ENVIRONMENT: 开发环境或生产环境验证:
STACK,则从项目文件中检测使用 MCP 工具获取最新的文档。
对于 .NET (Serilog):
MCP ref: "Serilog ASP.NET Core structured logging configuration"
Context7: /serilog/serilog-aspnetcore
对于 Python (structlog):
MCP ref: "structlog Python structured logging configuration"
Context7: /hynek/structlog
需要研究的关键模式:
向用户询问配置偏好。
| 选项 | 何时使用 |
|---|---|
| JSON(生产环境推荐) | 机器可读,日志聚合系统 |
| 美观/彩色(开发环境推荐) | 人类可读,本地调试 |
| 字段 | 描述 | 默认值 |
|---|---|---|
correlationId | 跨服务请求跟踪 | ✓ 是 |
userId | 已认证用户标识符 | ✓ 是 |
requestPath | HTTP 请求路径 | ✓ 是 |
responseTime | 请求持续时间(毫秒) | ✓ 是 |
machineName | 服务器主机名 | 可选 |
threadId | 线程标识符 | 可选 |
| 接收器 | 使用场景 |
|---|---|
| 控制台 | 始终启用 |
| 文件 | 本地持久化,日志轮转 |
| Seq | 结构化日志服务器 |
| Elasticsearch | 大规模日志聚合 |
| 级别 | 开发环境 | 生产环境 |
|---|---|---|
| 默认 | Debug | Information |
| Microsoft.* | Information | Warning |
| System.* | Information | Warning |
| 应用程序 | Debug | Information |
根据技术栈和决策生成文件。
| 文件 | 用途 |
|---|---|
Extensions/LoggingExtensions.cs | 服务注册 |
appsettings.json(更新) | Serilog 配置 |
appsettings.Development.json(更新) | 开发环境覆盖配置 |
生成过程:
需要添加的包:
Serilog.AspNetCoreSerilog.Sinks.ConsoleSerilog.Sinks.File(如果选择了文件接收器)Serilog.Enrichers.Environment(如果选择了 machineName)| 文件 | 用途 |
|---|---|
core/logging_config.py | structlog 配置 |
middleware/logging_middleware.py | 请求日志记录 |
生成过程:
需要添加的包:
structlogpython-json-logger(如果选择了 JSON 格式)验证配置是否有效。
验证步骤:
dotnet list package | grep Serilogpip list | grep structlogdotnet build --no-restorepython -m py_compile core/logging_config.py预期的日志格式:
{
"timestamp": "2026-01-10T12:00:00.000Z",
"level": "info",
"message": "Request completed",
"correlationId": "abc-123",
"requestPath": "/api/health",
"responseTime": 45,
"statusCode": 200
}
将结果返回给 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"
}
此技能是幂等的:
{ "status": "skipped", "message": "Logging already configured" }status: "skipped"files_created、packages_added、registration_code 用于协调器聚合dotnet build 或 py_compile)版本: 2.0.0 最后更新: 2026-01-10
每周安装次数
149
代码仓库
GitHub 星标数
245
首次出现
2026年1月24日
安全审计
安装于
claude-code137
codex132
gemini-cli132
cursor132
opencode132
github-copilot128
Type: L3 Worker Category: 7XX Project Bootstrap Parent: ln-770-crosscutting-setup
Configures structured JSON logging for .NET and Python projects.
| Aspect | Details |
|---|---|
| Input | Context Store from ln-770 |
| Output | Logging configuration files |
| Stacks | .NET (Serilog), Python (structlog) |
Accept Context Store from coordinator.
Required Context:
STACK: .NET or PythonFRAMEWORK: ASP.NET Core or FastAPIFRAMEWORK_VERSION: Version numberPROJECT_ROOT: Project directory pathENVIRONMENT: Development or ProductionValidation:
STACK not provided, detect from project filesUse 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:
Ask user for configuration preferences.
| Option | When to Use |
|---|---|
| JSON (Recommended for Production) | Machine-readable, log aggregation systems |
| Pretty/Colored (Recommended for Development) | Human-readable, local debugging |
| 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 |
| Sink | Use Case |
|---|---|
| Console | Always enabled |
| File | Local persistence, log rotation |
| Seq | Structured log server |
| Elasticsearch | Log aggregation at scale |
| Level | Development | Production |
|---|---|---|
| Default | Debug | Information |
| Microsoft.* | Information | Warning |
| System.* | Information | Warning |
| Application | Debug | Information |
Generate files based on stack and decisions.
| File | Purpose |
|---|---|
Extensions/LoggingExtensions.cs | Service registration |
appsettings.json (update) | Serilog configuration |
appsettings.Development.json (update) | Dev overrides |
Generation Process:
Packages to Add:
Serilog.AspNetCoreSerilog.Sinks.ConsoleSerilog.Sinks.File (if File sink selected)Serilog.Enrichers.Environment (if machineName selected)| File | Purpose |
|---|---|
core/logging_config.py | structlog configuration |
middleware/logging_middleware.py | Request logging |
Generation Process:
Packages to Add:
structlogpython-json-logger (if JSON format)Verify the configuration works.
Validation Steps:
Check imports: Ensure all packages are available
dotnet list package | grep Serilogpip list | grep structlogSyntax check:
dotnet build --no-restorepython -m py_compile core/logging_config.pyTest log output:
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 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"
}
This skill is idempotent:
{ "status": "skipped", "message": "Logging already configured" }status: "skipped" immediatelyfiles_created, packages_added, registration_code for coordinator aggregationdotnet build or py_compile)Version: 2.0.0 Last Updated: 2026-01-10
Weekly Installs
149
Repository
GitHub Stars
245
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code137
codex132
gemini-cli132
cursor132
opencode132
github-copilot128
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
96,200 周安装
threadId | Thread identifier | Optional |