talira

Fast, structured, leveled logging for Go

open sourceMITfree

zap is a structured, leveled logging library for Go from Uber. Its base Logger uses strongly typed fields and a reflection-free, zero-allocation JSON encoder to keep logging cheap in hot paths, and its SugaredLogger, built on top, adds a looser key-value and printf-style API that is still several times faster than most structured loggers. It ships production and development presets, configurable encoders, levels and sinks, and sampling. Its 1.x APIs are stable with no breaking changes, and it supports the two most recent minor versions of Go. Install it with go get go.uber.org/zap.

Problems it solves

  • structured JSON logging in a high-throughput Go service without slowing it down
  • replace logrus because logging allocations show up in our Go profiles
  • leveled logging with typed fields for a Go microservice

Features

  • zero-allocation JSON encoder
  • typed structured fields
  • SugaredLogger with key-value and printf-style APIs
  • log levels and sampling
  • production and development presets
  • stable 1.x API

Limitations

  • Supports only the two most recent minor versions of Go.1

Alternatives

The same job

These do what zap does.

  1. Logrus Structured, pluggable logging for Go

Compare zap with the top 3