Thanks to visit codestin.com
Credit goes to github.com

Skip to content

This is a logrus hook for rotating log files. This is basically a wrapper around the lumberjack library.

License

Notifications You must be signed in to change notification settings

tinkernels/rotatefilehook

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RotateFileHook

This is a simple hook for logrus to write rotated log files using https://github.com/natefinch/lumberjack

Example

package main

import (
	"github.com/sirupsen/logrus"
	"github.com/tinkernels/rotatefilehook"
)

rotateFileHook, err := rotatefilehook.NewRotateFileHook(rotatefilehook.RotateFileConfig{
    Filename:   "logfile.log",
    MaxSize:    5, // the maximum size in megabytes
    MaxBackups: 7, // the maximum number of old log files to retain
    MaxAge:     7, // the maximum number of days to retain old log files
    LocalTime:  true,
    Levels:     []logrus.Level{logrus.InfoLevel, logrus.WarnLevel},
    Formatter:  &logrus.TextFormatter{FullTimestamp: true},
})
if err != nil {
    panic(err)
}
var logger = logrus.New()
logger.AddHook(rotateFileHook)

About

This is a logrus hook for rotating log files. This is basically a wrapper around the lumberjack library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%