Implements consistent structured logging standards across Golang services.
Install
mkdir -p .claude/skills/logging && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2561" && unzip -o skill.zip -d .claude/skills/logging && rm skill.zipInstalls to .claude/skills/logging
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Standards for structured logging and observability in Golang. Use when adding structured logging or tracing to Go services.Key capabilities
- →Configure structured JSON logging
- →Implement leveled logging
- →Inject correlation IDs into logs
- →Standardize log formats
How it works
It uses structured handlers to inject request-scoped attributes and correlation IDs into logs for machine and human readability.
Inputs & outputs
When to use logging
- →Add structured logging to api
- →Configure zap logger
- →Standardize log formats
About this skill
Golang Logging Standards
Priority: P1 (HIGH)
Principles
- Structured Logging: Use JSON or structured key-value attributes. Machine-readable and filterable.
- Strict Single-Log Boundary: Log errors once where they are handled or translated at the boundary (service or handler level). Never double-log in repository, utility, or deep helper functions—wrap and return errors instead.
- Typed Context Keys: Always use private typed keys (
type ctxKey string) for storing and retrieving request-scoped logger attributes. - Business Traceability vs PII Redaction: Include non-sensitive business identifiers (e.g. tenant ID, organization code, order number) for traceability. Strictly redact credentials, API tokens, passwords, and sensitive PII.
- Leveled Logging: Debug, Info, Warn, Error.
- No
log.Fatal: Avoid terminating apps inside libraries. Return errors instead; onlymain()should handle process exit.
Libraries
log/slog(Recommended Stdlib): Stdlib since Go 1.21. Fast, structured, zero-dep.- Zap (
uber-go/zap): Production-grade structured logger for high-throughput microservices. - Zerolog: Zero allocation, fast JSON logger.
Workflow: Set Up Structured Logging
- Initialize structured logger at startup in
main()with standard JSON output. - Inject request correlation IDs (TraceID, RequestID) via middleware using typed context keys.
- Pass logger via context (
logger.FromContext(ctx)) or constructor injection. - Log at the application boundary on error; wrap errors upstream without intermediate logging.
See slog setup and usage examples
Anti-Patterns
- No Double-Logging: Do not log an error in the repository/database helper AND log it again in the service/handler.
- No fmt.Println in production: Use structured, leveled loggers.
- No Untyped Context Keys: Avoid
context.WithValue(ctx, "logger", l)with raw string keys. - No Secrets in Logs: Redact bearer tokens, passwords, and sensitive personal info.
- No log.Fatal in libraries: Return errors; only
main()should callos.Exit.
References
When not to use it
- →Using fmt.Println in production
- →Terminating applications inside libraries
Prerequisites
Limitations
- →Requires Go 1.21 for standard library slog
- →Libraries must return errors instead of exiting
How it compares
It enforces structured, leveled logging standards instead of unstructured print statements.
Compared to similar skills
logging side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| logging (this skill) | 2 | 2mo | No flags | Beginner |
| go-logging-observability | 0 | 6mo | No flags | Intermediate |
| architecture-patterns | 55 | 4mo | No flags | Advanced |
| workflow-orchestration-patterns | 10 | 4mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by HoangNguyen0403
View all by HoangNguyen0403 →You might also like
go-logging-observability
riordanpawley
Build and review production-grade Go logging and observability with `log/slog` and OpenTelemetry. Use when adding or refactoring logs, instrumenting request paths, defining event schemas, reducing log cost/cardinality, enforcing redaction/PII policy, correlating logs with traces, or reviewing Go ser
architecture-patterns
wshobson
Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use when architecting complex backend systems or refactoring existing applications for better maintainability.
workflow-orchestration-patterns
wshobson
Design durable workflows with Temporal for distributed systems. Covers workflow vs activity separation, saga patterns, state management, and determinism constraints. Use when building long-running processes, distributed transactions, or microservice orchestration.
golang-pro
sickn33
Master Go 1.21+ with modern patterns, advanced concurrency, performance optimization, and production-ready microservices. Expert in the latest Go ecosystem including generics, workspaces, and cutting-edge frameworks. Use PROACTIVELY for Go development, architecture design, or performance optimization.
go-concurrency-patterns
wshobson
Master Go concurrency with goroutines, channels, sync primitives, and context. Use when building concurrent Go applications, implementing worker pools, or debugging race conditions.
go
grafana
Best practices for working with Go codebases. Use when writing, debugging, or exploring Go code, including reading dependency sources and documentation.