Skip to content

Logrus vs zerolog

Which should you use? A side-by-side look at what each one does, who it suits, what it costs, how hard it is to set up, and where each falls short.

Logrus

Open source · MIT

A structured logger for Go that is API-compatible with the standard library log package.

zerolog

Open source · MIT

A fast Go logging library that writes structured JSON with almost no memory allocation.

The short answer

Choose Logrus if you need…

  • Go developers with existing code that already uses Logrus
  • Teams that want a drop-in replacement for the standard log package with structured fields
  • Projects that send logs to JSON-based systems such as Logstash or Splunk
  • Developers who want to attach extra hooks to send errors to other services

Choose zerolog if you need…

  • Go developers who want machine-readable JSON logs
  • Backend services where logging overhead matters
  • Teams that log structured fields and send logs to log-processing tools
  • Developers who want a chained, typed logging API

Side-by-side

Logruszerolog
TypeLibraryLibrary
PriceFree and open sourceFree and open source
LicenceMITMIT
GitHub stars25.8k12.5k
Setup difficultyBeginnerBeginner
How you get itInstall with a package managerInstall with a package manager
Main languageGoGo
Last code update34 days ago23 days ago

What each one is

Logrus

Logrus is a logging library for the Go programming language. It records messages with named fields, such as user IDs or request details, so logs can be searched and parsed by tools. It can output colored text for development or JSON for log systems like Logstash or Splunk. The README states the project is now in maintenance mode, focused on security, bug fixes, and performance.

zerolog

Zerolog is a logging library for the Go programming language. It records events as structured JSON (or optionally CBOR), where each message can carry typed key-value fields such as strings, numbers, and errors. It is built to avoid allocations and reflection, which the README says keeps it fast and light on memory.

Best for

Logrus

  • Go developers with existing code that already uses Logrus
  • Teams that want a drop-in replacement for the standard log package with structured fields
  • Projects that send logs to JSON-based systems such as Logstash or Splunk
  • Developers who want to attach extra hooks to send errors to other services

zerolog

  • Go developers who want machine-readable JSON logs
  • Backend services where logging overhead matters
  • Teams that log structured fields and send logs to log-processing tools
  • Developers who want a chained, typed logging API

Strengths

Logrus

  • API-compatible with the Go standard library logger, so switching is simple
  • Supports structured fields and both text and JSON output formats
  • Supports hooks and custom formatters and outputs

zerolog

  • Designed for low or zero allocation, per the README benchmarks section
  • Strongly typed fields and a simple chaining API
  • Supports leveled logging, sampling, hooks, and log/slog integration

Not ideal for

Logrus

  • New Go projects that want actively developed features, since the README says new features are not planned and it is in maintenance mode; the README points to alternatives such as Zerolog, Zap, and Apex
  • Non-Go projects, because it is a Go library
  • Projects that need the lowest possible logging overhead, since the README mentions that reporting the caller adds 20 to 40 percent overhead in its tests

zerolog

  • People who want readable colored console output by default: the README says pretty printing via ConsoleWriter is available but inefficient
  • Non-Go projects, since it is a Go package
  • Beginners who need a full logging framework with rotation or file management, which the README does not describe

Trade-offs

Logrus

  • The README says the project is in maintenance mode and new features are not planned
  • Adding the calling method as a field has measurable performance overhead according to the README
  • The README is truncated, so some details on hooks and configuration are not visible here

zerolog

  • Chained calls silently do nothing unless Msg or Msgf is called, and the compiler will not warn you
  • By default it writes every level, including trace, to stderr until SetGlobalLevel is called
  • Pretty console output is available but slower, as the README notes

Getting started

Logrus

Install the library

go get github.com/sirupsen/logrus
Step-by-step guide: how to use Logrus

zerolog

Install the global logger package

go get -u github.com/rs/zerolog/log
Step-by-step guide: how to use zerolog

Frequently asked questions

What is the difference between Logrus and zerolog?

Logrus: A structured logger for Go that is API-compatible with the standard library log package. zerolog: A fast Go logging library that writes structured JSON with almost no memory allocation. Logrus suits go developers with existing code that already uses logrus, while zerolog suits go developers who want machine-readable json logs.

Are Logrus and zerolog free?

Logrus: Free and open source. zerolog: Free and open source.

Is Logrus or zerolog more popular?

Logrus has more GitHub stars (25.8k) than zerolog (12.5k). Popularity isn't the same as fit — check which one matches your use case above.

What are other alternatives to Logrus and zerolog?

Other options people compare them with include zap.

Keep comparing

Built from our catalogue entries for both products: open-source details come from each project's README (AI-assisted, refreshed weekly) and GitHub data; AI-tool details are editorial. Spotted something wrong? Let us know from either product's page.