Zap is the logging framework for Go developed by Uber. It offers a powerful API for building structured loggers. Use this tag for questions related to the usage of the zap library in Go.
The package uber-go/zap
is a logging framework used to add structured, leveled logging to a Go application.
The most frequently used packages are:
zap
that contains the main abstractionszapcore
that contains the logic and types for constructing bespoke loggers
A simple example of how to use Zap:
logger, _ := zap.NewDevelopment()
logger.Info("hello world", zap.String("foo", "bar"))
Useful packages that extend Zap functionality:
gRPC interceptors:
github.com/grpc-ecosystem/go-grpc-middleware/logging/zap
protoc
plugin to implementMarshalLogObject()
for protobuffer messages:github.com/kazegusuri/go-proto-zap-marshaler