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.

Evaluated Mar 06, 2026 (0d ago) v1.x
Homepage ↗ Repo ↗ Developer Tools zerolog go golang logging structured-logging zero-allocation json performance
⚙ Agent Friendliness
68
/ 100
Can an agent use this?
🔒 Security
96
/ 100
Is it safe for agents?
⚡ Reliability
92
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
88
Error Messages
82
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
92
Secret Handling
88

MIT licensed. Minimal dependencies. Avoid logging sensitive data — typed field API makes explicit what's logged.

⚡ Reliability

Uptime/SLA
100
Version Stability
90
Breaking Changes
88
Error Recovery
90
AF Security 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

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Local library — no authentication required. MIT licensed.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

MIT licensed. Zero cost.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

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.

$99

Scores are editorial opinions as of 2026-03-06.

5215
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered