zerolog

A zero-allocation, chaining-API JSON logger for Go built for both structured production output and pretty local development logs.

Library
Go
vv1.35.1
12,495stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
67/100Good
Development Activity72
Maintenance28
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture82
Code Quality85
Innovation80
Learning Curve70

zerolog is a structured logging library for Go designed around a single goal: emit JSON log events without the allocations that typically come from reflection-based marshaling. Instead of building up a struct and serializing it, zerolog’s chaining Event API appends typed fields directly onto a byte buffer, giving it performance close to hand-written byte concatenation while keeping the call-site ergonomic (log.Info().Str("foo", "bar").Msg("hello")).

The core package stays intentionally small — a Logger, an Event, and an encoder abstraction that can target JSON or CBOR — while optional capability lives in subpackages: log for a ready-to-use global logger, hlog for net/http middleware, diode for a non-blocking ring-buffer writer under load, journald and syslog writers for platform logging targets, and pkgerrors for attaching stack traces to logged errors. A ConsoleWriter renders the same JSON events as colorized, human-readable lines for local development without changing how the application logs.

What You Get

  • A chaining Event builder (log.Info().Str(...).Int(...).Msg(...)) that writes typed fields straight to a byte buffer with no intermediate struct or reflection
  • Seven log levels (trace through panic) plus a no-level Log() call, with a package-wide SetGlobalLevel filter and per-logger level overrides
  • Sub-loggers via With() that carry contextual fields (request ID, component name, etc.) into every event logged through them, safely shareable across goroutines
  • A ConsoleWriter for colorized, human-readable output during development, with fully customizable field/level/message formatting
  • Hooks for injecting computed fields or side effects into every event, and a Sampler interface for rate-limiting noisy log lines
  • Optional CBOR binary encoding as a drop-in alternative to JSON via build tag
  • Ready-made integrations: hlog (HTTP middleware), diode (non-blocking writer for bursty workloads), journald/syslog writers, and pkgerrors for stack-trace-aware error logging
  • A log/slog compatible handler for projects standardizing on the Go standard library’s structured logging interface

Common Use Cases

  • Structured JSON logging in latency-sensitive services (APIs, proxies, daemons) where log-line allocation shows up in profiles
  • Attaching request-scoped context (user ID, trace ID, route) to every log line inside an HTTP handler via hlog middleware and a With()-derived sub-logger
  • Local development with human-readable, colorized console output that switches to JSON in production by swapping the output writer
  • High-throughput or bursty logging paths where a blocking writer would create backpressure, using the diode non-blocking ring buffer
  • Shipping logs to systemd’s journal or syslog directly from a Go service via the journald/syslog writer packages
  • Attaching formatted stack traces to error-level logs for services using github.com/pkg/errors, via the pkgerrors integration

Under The Hood

Architecture The core zerolog package centers on a Logger struct that pairs an io.Writer (upgraded to a LevelWriter if the caller provides one) with a level, an optional Sampler, a hook list, and a pre-encoded context byte slice. Calling a level method (Info(), Error(), etc.) produces an Event that appends fields directly to a shared buffer via an encoder interface, avoiding intermediate struct allocation; the buffer is only flushed to the writer on Msg/Send. With() snapshots the logger’s context into a Context value, letting callers build immutable sub-loggers that carry fields (request ID, component name) into every subsequent event without mutating the parent. Optional behavior is pushed into leaf packages rather than the core: log wraps a package-level global Logger, hlog adds net/http middleware that stores a Logger in the request context, diode wraps any writer in a lock-free ring buffer for non-blocking writes, and journald/syslog provide platform-specific writer implementations — none of which the core package depends on.

Tech Stack Written in Go (module targets Go 1.23) with a deliberately small dependency surface: github.com/rs/xid for compact ID generation, github.com/mattn/go-colorable and go-isatty for cross-platform console color support in ConsoleWriter, github.com/coreos/go-systemd/v22 for the journald writer, and github.com/pkg/errors (consumed only by the optional pkgerrors stack-trace subpackage). Encoding is abstracted behind an encoder interface with build-tag-selected implementations in internal/json and internal/cbor, so the same Event API can emit either format. CI runs via a single GitHub Actions workflow (.github/workflows/test.yml).

Code Quality The repository pairs most implementation files with a _test.go counterpart (16 test files covering the array/binary encoders, context, events, hooks, sampling, and the console writer), plus a dedicated benchmark_test.go reflecting the project’s performance focus. Errors are handled idiomatically — Err() short-circuits to an info-level event when passed nil, and the pkgerrors package layers formatted stack traces on top rather than swallowing failures. Public API surfaces are documented with godoc comments throughout log.go, event.go, and context.go, and example-driven tests (log_example_test.go, hlog_example_test.go, diode_example_test.go) double as executable documentation.

What Makes It Unique Where most Go JSON loggers build an intermediate representation (map, struct, or interface{} slice) and hand it to encoding/json, zerolog’s Event writes encoded bytes for each field as soon as it’s called, so a fully-populated log line is close to a single allocation-free buffer append. It applies this same design to both JSON and CBOR output through one encoder abstraction, and extends it past the core logger into a non-blocking writer (diode) for cases where even a fast writer becomes a bottleneck under bursty load — a concern most logging libraries leave entirely to the caller.

Used by 15 apps in this directory

Go
82%
AGPL 3.0

Beta9

Developer Tools · AI Development · Data Engineering

1,762

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
84
Repo Health
78
Technical
67
Dependency
Built with
Go82%
Python17%
Updated 3 days ago
Go
79%
Apache 2.0

Dolt

Databases · Data Engineering · Developer Tools

24,298

The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.

View details
90
Repo Health
9
Technical
67
Dependency
Built with
Go79%
Shell20%
Updated 2 days ago
TypeScript
71%
AGPL 3.0

Firecrawl

AI Development · Developer Tools

174,227

Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.

View details
89
Repo Health
83
Technical
66
Dependency
Built with
TypeScript71%
Python14%
Updated today
Go
69%
MIT

Gotify

Monitoring · Developer Tools

15,818

A lightweight, self-hosted push notification server that sends and receives messages in real time over WebSocket, with a sleek web UI and a native Go plugin system.

View details
89
Repo Health
74
Technical
70
Dependency
Built with
Go69%
TypeScript30%
Updated 3 days ago
Go
65%
Other

Hanko

Security · Authentication

9,016

Open source, self-hostable authentication platform with passkeys, SAML SSO, and OAuth — the privacy-first alternative to Auth0 and Clerk.

View details
89
Repo Health
81
Technical
69
Dependency
Built with
Go65%
TypeScript30%
Updated 2 days ago
Go
61%
Apache 2.0

Harness Open Source

Developer Tools · Devops · Code Editors

38,169

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
89
Repo Health
79
Technical
64
Dependency
Built with
Go61%
TypeScript34%
Updated 2 days ago
Go
84%
MIT

Hatchet

AI Development · Developer Tools · Automation

7,812

A Postgres-backed orchestration engine for background tasks, AI agents, and durable workflows that replaces Redis queues and multi-datastore durable execution platforms with a single self-hostable service.

View details
88
Repo Health
83
Technical
68
Dependency
Built with
Go84%
PLpgSQL11%
Updated today
Go
97%
Apache 2.0

infracost

Devops · Developer Tools

12,499

Infracost shows cloud cost estimates for Terraform, CloudFormation, and AWS CDK before you deploy — in your terminal, editor, AI coding agent, and pull requests.

View details
79
Repo Health
78
Technical
68
Dependency
Built with
Go97%
Updated 6 days ago
Go
74%
Other

Notifuse

Marketing

2,089

Open-source, self-hosted alternative to Mailchimp, Brevo, and Klaviyo — send newsletters and transactional emails without per-email pricing or vendor lock-in.

View details
83
Repo Health
80
Technical
66
Dependency
Built with
Go74%
TypeScript23%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search