A fast, zero-allocation JSON logger for Go with a chaining API and structured logging.
Zerolog is a zero-allocation JSON logger for Go that provides blazing-fast structured logging. It uses a chaining API to write log events without heap allocations or reflection, focusing exclusively on efficient JSON output while offering features like leveled logging, sampling, hooks, and context integration.
Go developers building high-performance applications where logging speed and low overhead are critical, such as microservices, APIs, or systems requiring extensive structured logging.
Developers choose Zerolog for its exceptional performance, zero-allocation design, and simple yet powerful API that outperforms alternatives like Zap, Logrus, and the standard library while maintaining full structured logging capabilities.
Zero Allocation JSON Logger
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses a unique chaining API to avoid heap allocations and reflection, with benchmarks showing 0 allocations per operation for many log events.
Dedicated to JSON output with strongly-typed fields, making it ideal for log aggregation systems like ELK or Splunk.
Provides a slog.Handler to route Go's standard log/slog records through zerolog, allowing seamless use of familiar APIs with zerolog's backend.
Includes log sampling, hooks, error logging with stack traces, and built-in integration with net/http and context.Context for comprehensive logging needs.
The ConsoleWriter for human-readable output is explicitly labeled as inefficient, making it unsuitable for production use where both readability and performance are required.
Zerolog does not deduplicate fields, which can lead to multiple keys in JSON output and potential parsing issues in log consumers.
UpdateContext is not concurrency-safe, requiring careful use of child loggers with the With() method in concurrent environments, adding boilerplate code.
Forgetting to call Msg or Msgf at the end of a chain results in no log output without compile-time errors, leading to silent failures and debugging challenges.