Skip to content
Back to skills

Structured Logging

ASecurity

Adopt structured, leveled JSON logging with consistent fields and correlation IDs

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 3, 2026
ai-agentsgobackend

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add black141312/ada --skill structured-logging --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Structured Logging?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Structured Logging
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/black141312-structured-logging/badge)](https://www.skillsdirectory.com/skills/black141312-structured-logging)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: structured-logging
description: Adopt structured, leveled JSON logging with consistent fields and correlation IDs
category: observability
---

# Structured Logging

Reach for this when grep-on-plaintext logs stop scaling — you need to filter, aggregate, and correlate logs in a log backend.

1. Pick a structured logger (pino, zap, structlog, slog) and configure JSON output to stdout; let the platform handle shipping.
2. Define a base logger with always-present fields: `service`, `env`, `version`, and a `level`.
3. Bind request-scoped context (`request_id`, `trace_id`, `user_id` if non-PII) via child loggers / context so every line in a request shares correlation keys.
4. Use levels deliberately: `error` for actionable failures, `warn` for recoverable anomalies, `info` for lifecycle events, `debug` for diagnostics off by default in prod.
5. Log events as `message` + structured fields, never string-concatenated values (`log.info('order placed', { order_id, amount })`).
6. Set log level from an env var and confirm JSON parses and correlation IDs thread through a sample request.

## Rules
- Never log secrets, tokens, passwords, full card/PII; add a redaction list and apply it at the logger, not per call site.
- One event per log line; don't split a single event across multiple lines.
- Reuse field names consistently across the codebase (`user_id` everywhere, not `userId`/`uid`).
- Don't log inside hot loops at `info`; guard expensive payloads behind level checks.
- Include `trace_id` so logs join traces; emit it from the same context source.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…