Skip to content

Logrus vs zap

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.

zap

Open source · MIT

A fast, structured logging library for Go programs.

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 zap if you need…

  • Go developers building services that log heavily
  • Teams that want structured, machine-readable log output
  • Projects where logging overhead in hot code paths is a concern
  • Developers who want a choice between typed and loosely typed logging APIs

Side-by-side

Logruszap
TypeLibraryLibrary
PriceFree and open sourceFree and open source
LicenceMITMIT
GitHub stars25.8k24.7k
Setup difficultyBeginnerBeginner
How you get itInstall with a package managerInstall with a package manager
Main languageGoGo
Last code update34 days ago50 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.

zap

Zap is a logging library for the Go programming language. It writes log messages with levels (such as info or error) and attached key-value details, so logs are easy to search and analyze. Developers use it in server code where logging speed matters, and it offers two APIs: a faster strongly typed one and a looser, more convenient one.

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

zap

  • Go developers building services that log heavily
  • Teams that want structured, machine-readable log output
  • Projects where logging overhead in hot code paths is a concern
  • Developers who want a choice between typed and loosely typed logging APIs

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

zap

  • The README reports strong benchmark results against several other Go logging packages, with the caveat that benchmarks should be taken with a grain of salt
  • Offers both a strongly typed Logger and a looser SugaredLogger so you can choose the trade-off
  • Stable API with a stated commitment to no breaking changes in the 1.x series

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

zap

  • Non-Go projects, since it is only for Go (reason: it is a Go library)
  • Beginners who only need simple print statements (reason: setup and typed fields add concepts to learn)
  • Projects that must use only the standard library's log/slog (reason: zap is a separate dependency with its own API)

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

zap

  • Only supports the two most recent minor versions of Go, according to the README
  • Typed Logger API requires more verbose code than the SugaredLogger
  • Performance claims come from the project's own benchmark suite, so independent results may differ

Getting started

Logrus

Install the library

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

zap

Install zap into a Go module

go get -u go.uber.org/zap
Step-by-step guide: how to use zap

Frequently asked questions

What is the difference between Logrus and zap?

Logrus: A structured logger for Go that is API-compatible with the standard library log package. zap: A fast, structured logging library for Go programs. Logrus suits go developers with existing code that already uses logrus, while zap suits go developers building services that log heavily.

Are Logrus and zap free?

Logrus: Free and open source. zap: Free and open source.

Is Logrus or zap more popular?

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

What are other alternatives to Logrus and zap?

Other options people compare them with include zerolog.

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.