Repolode
uber-go

uber-go/zap

A fast, structured, leveled logging library for Go with both a zero-allocation Logger and a looser SugaredLogger API.

Stars
24,678
Forks
1,575
Open issues
201
Last commit
last month

What is it?

Zap is a logging library for Go that writes structured log entries with typed key-value fields and supports log levels. It is aimed at applications that log in hot code paths, where reflection-based serialization and string formatting would add significant CPU cost and allocations.

Zap offers two APIs. The Logger uses strongly typed Field values and avoids allocations for most calls, while the SugaredLogger accepts loosely typed key-value pairs and printf-style formatting at a modest performance cost. Both are built on a reflection-free JSON encoder. The project's own benchmark suite compares it against packages such as zerolog, slog, logrus and zap's peers.

The library is documented on pkg.go.dev, and its API is marked stable, with no breaking changes planned within the 1.x series. It requires the two most recent minor versions of Go.

Key features

  • 01Structured logging with strongly typed Field values.
  • 02SugaredLogger with loosely typed key-value and printf-style APIs.
  • 03Reflection-free, zero-allocation JSON encoder.
  • 04Leveled logging with a production and development preset.

Use cases

  • Logging in latency-sensitive Go services where allocation overhead matters.
  • Emitting JSON logs that log aggregation systems can parse.
  • Adding structured context fields to requests in backend services.

Quick start

  1. 1

    Install the zap library with go get

    go get -u go.uber.org/zap
  2. 2

    Create a production logger and log with the SugaredLogger

Things to know

  • Only supports the two most recent minor versions of Go.

In collections

Topics

FAQ

What is zap?
A fast, structured, leveled logging library for Go with both a zero-allocation Logger and a looser SugaredLogger API. Zap is a logging library for Go that writes structured log entries with typed key-value fields and supports log levels. It is aimed at applications that log in hot code paths, where reflection-based serialization and string formatting would add significant CPU cost and allocations.
Is zap free to use? What license does it have?
zap is open source under the MIT license. Check the license terms before using it in commercial products.
Is zap still maintained?
Updated within 6 months. The last commit to zap was on Sep 16, 2026.
What can I use zap for?
Logging in latency-sensitive Go services where allocation overhead matters. Emitting JSON logs that log aggregation systems can parse. Adding structured context fields to requests in backend services.
How do I install zap?
Install the zap library with go get: go get -u go.uber.org/zap Create a production logger and log with the SugaredLogger
Where can I get zap?
The source code and installation instructions are on GitHub: https://github.com/uber-go/zap

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects