Need help with zap?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

133 Stars 32 Forks MIT License 29 Commits 3 Opened issues


Alternative logging through zap

Services available


Need anything else?

Contributors list


Build Status Go Report Card GoDoc Join the chat at

Alternative logging through zap. Thanks for Pull Request from @yezooz


Start using it

Download and install it:

$ go get

Import it in your code:

import ""


See the example.

package main

import ( "fmt" "time"



func main() { r := gin.New()

logger, _ := zap.NewProduction()

// Add a ginzap middleware, which:
//   - Logs all requests, like a combined access and error log.
//   - Logs to stdout.
//   - RFC3339 with UTC time format.
r.Use(ginzap.Ginzap(logger, time.RFC3339, true))

// Logs all panic to error log
//   - stack means whether output the stack info.
r.Use(ginzap.RecoveryWithZap(logger, true))

// Example ping request.
r.GET("/ping", func(c *gin.Context) {
    c.String(200, "pong "+fmt.Sprint(time.Now().Unix()))

// Example when panic happen.
r.GET("/panic", func(c *gin.Context) {
    panic("An unexpected error happen!")

// Listen and Server in


We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.