Introduction
zerolog is a fast, simple logger dedicated to JSON output. Its chaining API
writes JSON (or CBOR) events while avoiding allocations and reflection, so the
hot path stays cheap under load.
These docs pair short, task-oriented guides with a full Go API reference generated from the zerolog source at a pinned commit. The reference covers every exported package, type, function, method and runnable example that ships in the module.
What zerolog optimises for
- Speed and low allocation on the logging path.
- Structured output — every event is a JSON object, not a formatted string.
- A small, composable API — a
Loggerwrites events,Writers andHooks extend behaviour, andLevels gate what is emitted.
Zerolog deliberately focuses on efficient structured logging. Human-readable
console output is available too, through the (intentionally slower)
zerolog.ConsoleWriter.
Packages in this module
The module ships more than the root logger:
github.com/rs/zerolog— the core logger, levels, fields, encoders, hooks.github.com/rs/zerolog/log— a package-level global logger wired toos.Stderr.github.com/rs/zerolog/hlog—net/httpmiddleware that attaches a logger to a request.github.com/rs/zerolog/diode— a non-blocking writer that drops on saturation.github.com/rs/zerolog/journald— a writer for systemd journal native protocol.github.com/rs/zerolog/pkgerrors— stack-trace capture forgithub.com/pkg/errors.github.com/rs/zerolog/slog— a bridge to the standard librarylog/slog.
Each package has its own page in the Go API tab, generated from source.
Where these docs come from
The guides are authored. The API reference is generated by
Sourcey from the zerolog repository using Sourcey's
native godoc adapter, which reads Go source, doc comments and Example
functions directly. The build is reproducible: the source is pinned to a single
commit and the exact command is recorded in the build evidence shipped with
these docs.