backend-structured-logging
Use when the user asks about structured logging, JSON logs, Pino, Winston, Serilog, structlog, correlation IDs, log levels, log sampling or PII redaction in…
от j4flmao★ 47 звёзд на GitHub
Установить backend-structured-logging в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Backend Structured Logging
Purpose
Design structured JSON logging with consistent schema, context propagation, and sampling.
Agent Protocol
Trigger
Exact user phrases: "structured logging", "JSON logging", "log format", "logging best practice", "log levels", "distributed tracing", "log correlation", "structured log", "logging library", "log aggregation", "log output", "log schema", "correlation ID".
Input Context
Before activating, verify:
- Logging framework (Winston/Pino/Serilog/Log4j/logrus/zerolog)
- Log aggregation system (Elasticsearch/Loki/CloudWatch/Datadog)
- Compliance requirements (audit log retention, PII handling, access logs)
Output Artifact
Logging schema and configuration as formatted text.
Response Format
# Log schema (JSON fields)
# Log levels and sampling rules
// Logger configuration
// Context propagation middleware
// PII redaction config
No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.
Completion Criteria
- Log schema defined with all required fields (timestamp, level, message, context)
- Log levels configured with production rules (ERROR/WARN/INFO, sampled DEBUG)
- Log output configured as JSON lines to stdout
- Context propagation implemented (correlation ID through all async boundaries)
- Sensitive data redaction with pattern-based masking
- Sampling strategy defined per log level
Max Response Length
200 lines of configuration and code.
Decision Tree
Which Log Level?
What happened?
├── Application cannot continue (OOM, DB connection lost for good)
│ └── FATAL — page on-call immediately
├── Request failed, user got an error
│ └── ERROR — alert if rate exceeds threshold
├── Request succeeded but degraded (fallback used, retry happened)
│ └── WARN — investigate if persistent
├── State transition normal (order created, user registered)
│ └── INFO — sampled in production
├── Need to trace request through the system
│ └── DEBUG — header-activated per request
└── Deep internal details (loop iterations, variable values)
└── TRACE — never enabled in production
What to Include in a Log Event?
What is the context?
├── Correlate to a request → include trace.id, span.id, http.request.id
├── Identify the service → include service.name, service.version
├── Describe the operation → include event.action, event.outcome, event.duration
├── Contains sensitive data → redact with pattern-based censor
├── Large payload (>10KB) → truncate or omit, log key reference instead
└── High cardinality (user IDs, order IDs) → OK as labels, not as metric tags
Workflow
Step 1: Log Schema Definition
Every log entry is a single JSON object with required fields: @timestamp (ISO 8601, millisecond precision, UTC), log.level (ERROR/WARN/INFO/DEBUG), log.logger (source class/module), message (human-readable summary), trace.id, span.id, service.name, service.environment, event.action, http.request.id. Follow Elastic Common Schema (ECS) for consistency across services.
{
"@timestamp": "2025-01-15T10:30:00.123Z",
"log.level": "INFO",
"log.logger": "checkout.service",
"message": "Order created successfully",
"trace.id": "abc123def456",
"span.id": "span-789",
"service.name": "checkout-service",
"service.version": "1.2.3",
"service.environment": "production",
"event.action": "order.create",
"event.outcome": "success",
"event.duration": 234,
"http.request.id": "req_4444",
"http.request.method": "POST",
"http.response.status_code": 201,
"url.path": "/api/orders",
"client.user.id": "user_98765",
"labels": { "team": "checkout", "feature": "new-checkout" }
}
Step 2: Log Level Discipline
| Level | Numeric | When to Use | Sample in Prod | Example |
|---|---|---|---|---|
| FATAL | 0 | Application cannot continue | 100% | OOM, DB unreachable |
| ERROR | 1 | Request cannot be served | 100% | External API 500, validation fails |
| WARN | 2 | Degradation but served | 100% | Circuit breaker opened, fallback used |
| INFO | 3 | State transition | 10% | User created, order placed |
| DEBUG | 4 | Development detail | 0-1% | SQL queries, function params |
| TRACE | 5 | Deep diagnosis | 0% | Variable values, loop iterations |
Production: only FATAL (100%), ERROR (100%), WARN (100%), INFO (sampled), DEBUG (disabled or header-activated). Per-request DEBUG: enabled via X-Debug-Log: true header for debugging specific requests.
Step 3: Logger Configuration by Language
// Pino — Node.js (fastest JSON logger)
import pino from 'pino';
const logger = pino({
level: process.env.LOG_LEVEL || 'info',
formatters: {
level(label) { return { 'log.level': label }; },
bindings() { return {}; },
log(obj) {
obj['@timestamp'] = new Date().toISOStrin
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/log-aggregation.md
- references/log-correlation-tracing.md
- references/log-format.md
- references/log-sampling-strategies.md
- references/log-shipping.md
- references/logging-aggregation.md
- references/logging-architecture.md
- references/structured-logging-implementation.md
FAQ
Что делает скилл backend-structured-logging?
Use when the user asks about structured logging, JSON logs, Pino, Winston, Serilog, structlog, correlation IDs, log levels, log sampling or PII redaction in logs. Produces a logging setup with a field schema. Not for tracing pipelines (use observability) or audit trails (use backend-audit-logging).
Как установить скилл backend-structured-logging?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл backend-structured-logging запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…