op / go-logging

Golang logging library
BSD 3-Clause "New" or "Revised" License
1.79k stars 272 forks source link

Rotating files #140

Open nurlybekovnt opened 5 years ago

nurlybekovnt commented 5 years ago

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

cedricve commented 5 years ago

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)