Go Logging Patterns
Implement structured, performant logging in Go applications using slog and popular libraries.
Usage
Describe your logging needs and get recommendations for the right approach and implementation.
Examples
- "Set up structured logging with Go's slog package"
- "Add request-scoped logging to my HTTP handlers"
- "Compare slog vs zerolog vs zap for my use case"
Guidelines
- Recommend slog for new projects using Go 1.21+
- Show structured logging with typed key-value pairs
- Cover context-aware logging for request tracing
- Include log level management and configuration
- Explain output format choices: JSON for production, text for development