Go Logging
Structured Go logging guide for slog, log levels, request-scoped context, and what to keep out of logs.
- CCM score
- 65 of 100
- skills.sh installs
- 1.2K
- GitHub stars
- 197
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers logger selection, structured key-value logging, log levels, request-scoped loggers, and sensitive-data exclusions
- Includes
references/LEVELS-AND-CONTEXT.mdfor level choice and context handling, andreferences/LOGGING-PATTERNS.mdfor handler setup, HTTP request logs, testing, andlogmigration - Enforces key-value attributes over interpolated messages,
snake_casekeys, and no secrets, PII, or unbounded data in logs - Designed for Go 1.21+ services that need production logging, and defers error-handling strategy to go-error-handling
Install
$ npx -y skills add cxuu/golang-skills --skill go-logging -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Go Logging
Compatibility:
log/slogrequires Go 1.21+;testing/slogtestrequires Go 1.22+.
Resource Routing
references/LEVELS-AND-CONTEXT.md- Read when choosing log levels, deciding logger-in-context versus explicit parameters, or excluding sensitive fields.references/LOGGING-PATTERNS.md- Read when configuring slog handlers, logging HTTP requests, testing handlers, or migrating fromlog.Printf.
Core Principle
Logs are for operators, not developers. Every log line should help someone diagnose a production issue. If it doesn't serve that purpose, it's noise.
Choosing a Logger
Normative: Use
log/slogfor new Go code.
slog is structured, leveled, and in the standard library (Go 1.21+). It
covers the vast majority of production logging needs.
Which logger?
├─ New production code → log/slog
├─ Trivial CLI / one-off → log (standard)
└─ Measured perf bottleneck → zerolog or zap (benchmark first)
Do not introduce a third-party logging library unless profiling shows slog
is a bottleneck in your hot path. When you do, keep the same structured
key-value style.
Structured Logging
Details
- Repository
- github.com/cxuu/golang-skills
- Categories
- Go, Backend & APIs, Debugging
- First seen
- Jun 3, 2026
More from cxuu/golang-skills
All 20- Go Generics1.1K
- Go Functions1.1K
- Go Declarations1.1K
- Go Code Review1.9K
- Go Testing1.5K
- Go Error Handling1.4K
- Go Concurrency1.4K
- Go Interfaces1.4K
- Go Linting1.4K
- Go Style Core1.4K
- Go Documentation1.4K
- Go Context1.4K
- Go Performance1.4K
- Go Naming1.4K
- Go Defensive1.4K
- Go Packages1.3K
- Go Functional Options1.3K
- Go Data Structures1.3K
- Go Control Flow1.3K
Similar to Go Logging
More Gologging-best-practicesaj-geddes/useful-ai-prompts748 installsStructured logging guide covering log levels, JSON formats, PII redaction, and centralized logging practices.
golang-samber-slogsamber/cc-skills-golang40.9K installsComposable slog.Handler packages for Go structured logging: pipelines, sampling, formatting, and backend sinks.
golang-error-handlingsamber/cc-skills-golang47.1K installsIdiomatic Go error handling covering wrapping, inspection, the single handling rule, and production-grade slog and samber/oops logging.
application-loggingaj-geddes/useful-ai-prompts504 installsStructured logging guide for Node.js, Python, Express, Flask, and ELK pipelines with clear do and don't rules.
go-contextcxuu/golang-skills1.4K installsGo context conventions covering placement, cancellation, deadlines, and when to store values in context.
python-observabilitywshobson/agents12.5K installsStructured logging, metrics, and tracing patterns for Python services with correlation IDs and log-level guidance.