📊

Go Logging Patterns

Verified

by Community

Covers logging in Go using the new slog package and popular libraries like zerolog and zap. Shows structured logging patterns, log levels, context-aware logging, and log output formatting for different environments.

gologgingslogstructuredobservability

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