structured-logging-design

Implement Go structured logging with slog, trace correlation, and PII redaction.

1|Updated Jun 20, 2026
One-click install
npx skills add https://github.com/shafibabar/SDLC-Artifact-Factory --skill structured-logging-design
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: structured-logging-design
Source: https://github.com/shafibabar/SDLC-Artifact-Factory/tree/main/skills/structured-logging-design
Command: npx skills add https://github.com/shafibabar/SDLC-Artifact-Factory --skill structured-logging-design

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill solves the issue of unsearchable, uncorrelated, and high-cost logging in production systems by enforcing structured JSON output and trace-context injection.

Core Features & Use Cases

  • Trace Correlation: Automatically binds OTel TraceID and SpanID to every log line for seamless pivoting between logs, metrics, and traces.
  • Production-Grade Standards: Enforces JSON-only output for machine indexing and strict PII/secret redaction via custom LogValuer types.
  • Use Case: A backend engineer can use this to refactor a legacy service using fmt.Printf into a high-performance, Kubernetes-compliant observability pipeline that integrates directly with Loki and Grafana.

Quick Start

Use the structured-logging-design skill to implement the traceHandler wrapper and configure the production JSON logger in your Go service.

Frequently Asked Questions about structured-logging-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement structured logging in Go with trace correlation?

Implement structured logging in Go with trace correlation by using log/slog to automatically bind OpenTelemetry TraceID and SpanID to every JSON log line, enabling seamless pivoting between logs, metrics, and traces in observability platforms.

What is the best way to enforce PII redaction in Go slog?

Enforce PII redaction in Go slog by utilizing custom LogValuer types to strictly sanitize secrets before output, ensuring production-grade JSON logs remain compliant while maintaining high-performance, zero-allocation logging on hot paths.

Does this structured logging approach work with Kubernetes and Loki pipelines?

Yes, this structured logging approach works with Kubernetes pipelines by enforcing JSON-formatted output directly to stdout, making logs immediately available for machine indexing and ingestion by systems like Loki and Grafana.

How do I configure context-aware log levels for zero-allocation logging in Go?

Configure context-aware log levels for zero-allocation logging in Go by setting up the production JSON logger with log/slog, allowing dynamic severity adjustments based on request context without impacting hot-path performance.

Why do I need structured JSON logs instead of fmt.Printf for backend services?

You need structured JSON logs instead of fmt.Printf to solve the issue of unsearchable, uncorrelated logs in production systems, enabling machine indexing, strict PII redaction, and direct trace-context injection for backend observability.