On this page
Overview
zerolog is a structured logging library for Go. Its chaining API adds typed fields and produces JSON or CBOR events with a low-allocation design. It also includes levels, sampling, hooks, context.Context and net/http integration, and a standard log/slog handler.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Build structured events by chaining typed fields into JSON output
Calls such as log.Info().Str(...).Int(...).Msg(...) add typed context to a log event. JSON is the default format and CBOR is available through a build tag.
Sources: [2]
Combine sampling, hooks, context.Context, and slog integration
The library supports sampling, hooks, contextual fields, context.Context, net/http, and a log/slog Handler for integration with application logging.
Sources: [2]
Best fit
Fits Go services that prioritize compact structured JSON logs with low allocation overhead
It is useful for APIs and workers that emit logs frequently and want typed structured fields with efficient JSON output; ConsoleWriter is available for human-readable development output.
Sources: [2]
Before adoption
v1.35.1 declares Go 1.23; do not retain pooled Events or Arrays beyond their lifecycle
The v1.35.1 go.mod declares Go 1.23. Events and Arrays are reused through sync.Pool, so references must not be retained after Msg/Send or outside callbacks. The chaining API also emits nothing unless a terminal method such as Msg or Msgf is called, with no compile-time error, so wrappers should be covered by tests.
Official sources
- [1]rs/zerolog — GitHub repository(2026-10-06)
- [2]zerolog v1.35.1 — README(2026-10-06)
- [3]zerolog v1.35.1 — go.mod(2026-10-06)
- [4]zerolog MIT license(2026-10-06)
Supplemental curator note
The chaining API builds structured events efficiently from fields through Msg or Send. Events and arrays are pooled internally, so references must not escape callbacks or outlive their documented lifecycle.
Try it in 3 steps
- 1
Get the source
git clone --depth 1 https://github.com/rs/zerolog.git - 2
Enter the repository
cd zerolog - 3
Check the official steps
Continue with the commands in the README Installation, Quick Start, or Getting Started section.
find . -maxdepth 1 -iname 'README*' -exec sed -n '1,220p' {} \; -quit
Growth
Growth trends · Last 30 days
12,514 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 3
- Open PRs
- 44
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- logging
- json
- golang
- structured-logging
- zerolog
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- OpenTelemetry Java2,457 Stars
1 shared tag(s) · 2 shared category(s)
embed OpenTelemetry APIs, SDKs, and OTLP exporters for traces, metrics, and logs in Java
Java - Sentry Cocoa1,124 Stars
1 shared tag(s) · 2 shared category(s)
capture errors, crashes, and performance context from Apple applications with the official Sentry SDK
Swift - Lazygit82,894 Stars
1 shared tag(s) · 1 shared category(s) · Same language
Bring staging, commits, branches, rebases, worktrees, and reflog operations into a keyboard-driven terminal Git UI
Go - Zap24,664 Stars
3 shared tag(s) · 2 shared category(s) · Same language
choose typed fields or a SugaredLogger for high-performance structured logging in Go
Go - Grafana Loki28,990 Stars
2 shared tag(s) · 1 shared category(s) · Same language
Aggregate large log volumes with Prometheus-style label indexes, LogQL, Grafana, and multi-tenant operations
Go - opa12,323 Stars
2 shared tag(s) · Same language
Define authorization and configuration rules in Rego and evaluate them separately
Go
Report incorrect information
Tell us if any listing information is incorrect or outdated.