Closed djarbz closed 11 months ago
Perhaps boring, but this is what I do (with zerolog as the upper layer):
var out io.WriteCloser
out = os.Stderr
if logfile != "" {
l := &lumberjack.Logger{
Filename: logfile,
MaxBackups: globalConf.GetInt("server.logs.backups"),
MaxSize: globalConf.GetInt("server.logs.size"),
MaxAge: globalConf.GetInt("server.logs.age"),
Compress: globalConf.GetBool("server.logs.compress"),
}
if globalConf.GetBool("server.logs.rotate-at-start") {
l.Rotate()
}
out = l
}
I like it, I will proceed with that method, simple enough and no need modify anything in the library.
Is it possible to rotate at the start of the application?