zerolog
Zero-allocation JSON logging library for Go. Achieves zero heap allocations for most logging operations through a fluent builder API that avoids interface{} boxing. Fastest Go structured logger in benchmarks. Method chaining builds log events: log.Info().Str('key', val).Int('count', n).Msg('message'). Used in high-performance Go services where logging overhead must be eliminated.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
MIT licensed. Minimal dependencies. Avoid logging sensitive data — typed field API makes explicit what's logged.
⚡ Reliability
Best When
You need the absolute minimum allocation overhead for logging in a performance-critical Go service — latency-sensitive agent systems handling millions of requests.
Avoid When
Logging performance isn't your bottleneck — zap or logrus are simpler with good enough performance for most services.
Use Cases
- • Add zero-allocation structured JSON logging to high-throughput Go agent services
- • Log in request hot paths where even small allocations impact GC pressure and latency
- • Implement structured agent service logging with automatic level filtering and JSON output
- • Add context propagation to Go agent logs: logger.With().Str('service', 'agent').Logger()
- • Dynamic log level changes at runtime via zerolog.SetGlobalLevel() without service restart
Not For
- • Applications where zero-allocation isn't critical — zap or logrus are simpler for typical services
- • Printf-style logging — zerolog's chaining API is more verbose than fmt.Sprintf or zap.Sugar
- • Developers unfamiliar with Go's allocation patterns — the zero-allocation benefit requires understanding the constraints
Interface
Authentication
Local library — no authentication required. MIT licensed.
Pricing
MIT licensed. Zero cost.
Agent Metadata
Known Gotchas
- ⚠ Log events are sent ONLY after .Msg('message') or .Send() — forgetting .Msg() means the log event is silently discarded
- ⚠ zerolog.GlobalLevel() controls the minimum level — below this level, .Str(), .Int() etc. are no-ops; events below threshold have truly zero cost
- ⚠ Sub-loggers for context: logger = log.With().Str('component', 'agent').Logger() — returns new logger with bound fields, not a reference to global
- ⚠ HTTP middleware: github.com/rs/zerolog/hlog provides request-ID, URL, method fields automatically for HTTP servers
- ⚠ zerolog.ConsoleWriter for development: log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) — human-readable console output instead of JSON
- ⚠ Context propagation: zerolog.Ctx(ctx) retrieves logger from context; log.Logger.WithContext(ctx) stores logger — standard pattern for request-scoped logging
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for zerolog.
Scores are editorial opinions as of 2026-03-06.