Zerolog is a structured JSON logging library for Go that prioritizes performance through zero-allocation design.
The tool solves the problem of high-overhead logging in performance-sensitive applications. Traditional logging often allocates memory during the logging process, which can impact throughput and latency. Zerolog addresses this by using a chaining API that constructs JSON log events without allocations or reflection. The library outputs structured logs as JSON by default, with optional CBOR encoding support. For development workflows requiring human-readable output, it provides a ConsoleWriter for pretty-printing, though this mode trades efficiency for readability.
Zerolog suits Go applications where logging overhead matters, particularly in high-throughput services or latency-sensitive systems. The library focuses exclusively on structured logging, making it a good fit for teams already committed to that approach. It offers leveled logging across seven levels from trace to panic, contextual field attachment with strong typing, log sampling, hooks, context.Context integration, and net/http middleware support. The README positions the tool as an evolution beyond Uber's zap library, claiming both a simpler API and superior performance characteristics. Teams should be aware that the chaining API requires explicit Msg or Msgf calls to complete a log statement; omitting these results in silent failures with no compile-time warning.
The project maintains active engagement with its codebase, incorporating feedback and expanding compatibility. Development shows responsiveness to ecosystem changes, including integration with Go's log/slog standard library interface. The maintainers demonstrate commitment to performance as a core concern, with benchmarking prominently featured in documentation. The project accepts community contributions and maintains a wiki tracking real-world adoption across various organizations and projects.