Rzap - Log rotate for uber-zap

rzap

Log rotate for uber-zap

How to install

go get github.com/winking324/rzap

How to use

rzap.NewGlobalLogger([]zapcore.Core{
    rzap.NewCore(&lumberjack.Logger{
        Filename:   "/your/log/path/app.log",
        MaxSize:    10,   // 10 megabytes, defaults to 100 megabytes
        MaxAge:     10,   // 10 days, default is not to remove old log files
        MaxBackups: 10,   // 10 files, default is to retain all old log files
        Compress:   true, // compress to gzio, default is not to perform compression
    }, zap.InfoLevel),
})

zap.L().Info("some message", zap.Int("status", 0))

Log to files at different levels

rzap.NewGlobalLogger([]zapcore.Core{
    rzap.NewCore(&lumberjack.Logger{
        Filename: "/path/to/info.log",
    }, zap.LevelEnablerFunc(func(level zapcore.Level) bool {
        return level <= zap.InfoLevel
    })),
    rzap.NewCore(&lumberjack.Logger{
        Filename: "/path/to/error.log",
    }, zap.LevelEnablerFunc(func(level zapcore.Level) bool {
        return level > zap.InfoLevel
    })),
})

zap.L().Info("some info message", zap.Int("status", 0))   // only output to /path/to/info.log
zap.L().Error("some error message", zap.Int("status", 1)) // only output to /path/to/error.log
Owner
ShanHui
Make your faith larger than your fears and your dreams larger than your doubts.
ShanHui
Similar Resources

Hook for sending events zap logger to telegram.

zaptelegram Hook for sending events to telegram for zap logger. Install: go get -u github.com/strpc/zaptelegram Basic usage: package main import ( "

Oct 15, 2022

Go starter project with Gin, Viper, postgres , redis, zap, prometheus metrics etc setup

Go REST Service Starter/Boilerplate Easily extendible REST API Service boilerplate aiming to follow idiomatic go and best practice. Any feedback and p

Jun 23, 2022

Alternative logging through zap.

wzap Alternative logging through zap Usage Start using it Download and install it: go get github.com/wyy-go/wzap Import it in your code: import "githu

Jan 8, 2022

A logrus.Hook that logs with a zap.Logger

zaprus Ever had a 3rd-party dependency requiring a logrus, but you're using zap? zaprus provides a logrus.Hook that makes a logrus.(Entry|Logger) repl

Feb 27, 2022

Zapctx: an encapsulation of zap, adding WithContext to the logger

Abstract zapctx is an encapsulation of zap, adding WithContext to the logger. Fe

Oct 14, 2022

a golang log lib supports level and multi handlers

go-log a golang log lib supports level and multi handlers Use import "github.com/siddontang/go-log/log" //log with different level log.Info("hello wo

Dec 29, 2022

Structured log interface

Structured log interface Package log provides the separation of the logging interface from its implementation and decouples the logger backend from yo

Sep 26, 2022

lumberjack is a log rolling package for Go

lumberjack Lumberjack is a Go package for writing logs to rolling files. Package lumberjack provides a rolling logger. Note that this is v2.0 of lumbe

Jan 1, 2023

CoLog is a prefix-based leveled execution log for Go

CoLog is a prefix-based leveled execution log for Go

What's CoLog? CoLog is a prefix-based leveled execution log for Go. It's heavily inspired by Logrus and aims to offer similar features by parsing the

Dec 14, 2022
logger wraps uber/zap and trace with opentelemetry

logger 特性 支持 uber/zap 日志 支持 log rolling,使用 lumberjace 支持日志追踪 支持debug、info、warn、e

Sep 17, 2022
Logger - A thin wrapper of uber-go/zap logger for personal project

a thin wraper of uber-go/zap logger for personal project 0. thanks uber-go/zap B

Sep 17, 2022
Log-server - Implement log server for gwaylib/log/adapter/rmsq

Implement server of github.com/gwaylib/log Base on https://github.com/gwaycc/lserver Build . env.sh cd cmd/web go build Deploy Install supd(Debian sy

Jan 3, 2022
Log to cloud object storage for golang. Zap extension.

cos-logger Log to cloud object storage for golang implemented as io.Writer. Use it as a plugin/extension to uber-go/zap logger Configure logger and ad

Jan 19, 2022
An golang log lib, supports tracking and level, wrap by standard log lib

Logex An golang log lib, supports tracing and level, wrap by standard log lib How To Get shell go get gopkg.in/logex.v1 source code import "gopkg.in/

Nov 27, 2022
Nginx-Log-Analyzer is a lightweight (simplistic) log analyzer for Nginx.
Nginx-Log-Analyzer is a lightweight (simplistic) log analyzer for Nginx.

Nginx-Log-Analyzer is a lightweight (simplistic) log analyzer, used to analyze Nginx access logs for myself.

Nov 29, 2022
Distributed-Log-Service - Distributed Log Service With Golang
Distributed-Log-Service - Distributed Log Service With Golang

Distributed Log Service This project is essentially a result of my attempt to un

Jun 1, 2022
Log-analyzer - Log analyzer with golang

Log Analyzer what do we have here? Objective Installation and Running Applicatio

Jan 27, 2022
Based uber/prototool
Based uber/prototool

Prototool Update: We recommend checking out Buf, which is under active development. There are a ton of docs for getting started, including for migrati

Dec 30, 2021
Uber-cute UUID's alternative !

UwUID ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⣿⣿⡆⠀⠀⢸⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀⣾⣿⡆⠀ ⠀⠀⠀⣿⣿⡇⠀⠀⢸⣿⢰⣿⡆⠀⣾⣿⡆⠀

Jul 22, 2022