Zero-allocation JSON logger for Go
open sourceMITfree
zerolog is a Go logging library dedicated to structured JSON output. Its chaining API writes JSON (or binary CBOR) log events while avoiding allocations and reflection, following the approach zap pioneered with a simpler API. It offers leveled logging, sampling, hooks, contextual fields, context.Context and net/http integration, and a ConsoleWriter for readable output during development (slower, by its own account).
Problems it solves
- fast structured JSON logging in my Go service without allocations
- add request context fields to every log line in a Go HTTP server
- sample high-volume debug logs in Go
Features
- structured JSON logging with zero or low allocation
- CBOR binary encoding
- leveled logging
- log sampling
- hooks and contextual fields
- context.Context and net/http integration
- pretty console output for development
Alternatives
The same job
These do what zerolog does.
