go-logging icon indicating copy to clipboard operation
go-logging copied to clipboard

Rotating files

Open nurlybekovnt opened this issue 6 years ago • 1 comments

Hi, thanks a lot for that great implementation of logger How and where can I add file rotationg(every day)? I want to hold logs for every single day in separate files, and I think it would be better if I implement this using goroutines

nurlybekovnt avatar Jul 01 '19 06:07 nurlybekovnt

This library is great: https://github.com/natefinch/lumberjack.

fileBackend := logging.NewLogBackend(&lumberjack.Logger{
Filename:   "./logs/log.log",
MaxSize:    2, // megabytes
Compress:   true, // disabled by default
}, "", 0)
logging.SetBackend(stdBackendLeveled, mqttBackend, fileBackend)

cedricve avatar Aug 06 '19 11:08 cedricve