zerolog
Zerolog is a fast, zero-allocation JSON logging library for Go that outputs structured logs in JSON format. It emphasizes performance through a chaining API that avoids reflection and memory allocations, making it suitable for high-throughput production systems.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | rs/zerolog |
| Owner | rs |
| Primary language | Go |
| License | MIT — OSI-approved |
| Stars | 12.5k |
| Forks | 628 |
| Open issues | 145 |
| Latest release | Unknown |
| Last updated | 2026-06-29 |
| Source | https://github.com/rs/zerolog |
What zerolog is
Zerolog provides a type-safe chaining API for structured JSON logging in Go, with support for contextual fields, multiple log levels, sampling, hooks, and integration with context.Context and net/http. It uses allocation-free JSON encoding and offers both JSON and CBOR output formats.
Get the zerolog source
Clone the repository and explore it locally.
git clone https://github.com/rs/zerolog.gitcd zerolog# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Chaining API requires explicit Msg() or Msgf() termination; missing it silently prevents logging with no compile error. Code review discipline is necessary.
- Contextual field addition uses strongly-typed methods (Str, Int, Float64, etc.). Verify type correctness at call sites to avoid runtime issues.
- Default output is os.Stderr. Explicitly configure output writers for production (file, syslog, network) to integrate with log aggregation systems.
- Log sampling must be configured explicitly via zerolog.NewSampler(); default is no sampling. Adjust for high-volume production workloads.
- Stack traces require opt-in via Stack() method and manual ErrorStackMarshaler configuration; they are not automatic on error logging.
When to avoid it — and what to weigh
- Pretty-printed console logging is primary use case — Zerolog's ConsoleWriter is intentionally simple and inefficient. If development teams require advanced pretty-printing, filtering, or colored output, use stdlib log or alternative loggers.
- Text-based log format required — Zerolog is JSON-first and does not provide efficient text logging. Projects requiring plain-text logs should consider stdlib log or logrus.
- Implicit error handling preferred — Zerolog requires explicit chaining with Msg() or Msgf() calls; forgetting them silently skips logging with no compile-time error. Teams preferring implicit logging or automatic panic handling may find this error-prone.
- Minimal external dependencies desired — While zerolog itself is lightweight, stack trace integration requires github.com/pkg/errors. Additional integration packages may introduce transitive dependencies.
License & commercial use
MIT License. Permissive OSI-approved license allowing commercial use, modification, and distribution with attribution and liability disclaimer. No restrictions on use or distribution model.
MIT License is permissive and clearly allows commercial use without additional licensing agreements or fees. Use in proprietary applications is permitted. No restrictions noted; standard attribution requirements apply.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Strong |
| Assessment confidence | High |
Zerolog itself has no built-in authentication, encryption, or access control—it is a local logging library. Security posture depends on output destination: ensure logs written to files have appropriate filesystem permissions; logs sent over network should use TLS; logs in cloud platforms should use IAM policies. No sensitive data masking is mentioned; sanitize secrets before logging. Reflect-free design reduces some attack surface compared to reflection-heavy loggers. Stack trace inclusion may expose internal implementation details; review stack output for sensitive information.
Alternatives to consider
Uber Zap
Pioneered zero-allocation structured logging in Go. Similar performance characteristics but larger feature set and more complex API. Zap may be overkill for simple cases; zerolog is simpler and faster for many workloads.
Go stdlib log/slog (1.21+)
Built-in structured logging with slog package. Less mature than zerolog, no zero-allocation guarantees, but eliminates external dependency. Suitable if targeting Go 1.21+ and avoiding third-party logging libraries.
logrus
Popular structured logging library with text and JSON output. Less performance-focused than zerolog; uses reflection and allocations. Better pretty-printing for development. Choose if text logging and ease-of-use outweigh performance needs.
Build on zerolog with DEV.co software developers
Zerolog delivers high-performance structured JSON logging with zero allocations. Whether you're building microservices, APIs, or cloud-native applications, our team can help you integrate and optimize logging for your infrastructure.
Talk to DEV.coRelated on DEV.co
Explore the category and the services that help you build with it.
zerolog FAQ
What does 'zero allocation' mean in zerolog?
Why do I need to call Msg() to log?
How do I output logs to files or cloud platforms?
Is zerolog production-ready?
Software development & web development with DEV.co
DEV.co is a software development agency delivering custom software development services to companies building on open source. Our software developers and web developers design, integrate, and ship production systems — spanning web development, APIs, AI, data, and cloud. If zerolog is part of your open-source observability roadmap, our team can implement, customize, migrate, and maintain it.
Need a production-ready logging solution for Go?
Zerolog delivers high-performance structured JSON logging with zero allocations. Whether you're building microservices, APIs, or cloud-native applications, our team can help you integrate and optimize logging for your infrastructure.