natefinch / lumberjack

lumberjack is a log rolling package for Go
MIT License
4.79k stars 591 forks source link

Rotate on daily based? #91

Open sriram275 opened 5 years ago

sriram275 commented 5 years ago

Is that possible to rotate logger based on daily instead maxSize ? Since we want to rotate log file daily irrespectie of the log file size.

Thanks, Sriram

joseluisq commented 4 years ago

Daily rotation files is also an option for me independently of size.

joseluisq commented 4 years ago

By the way, this is a duplicated of #54.

itrepablik commented 4 years ago

You can actually make a filename like this instead of a fixed filename value:

logFile := "logs/app_name_" + time.Now().Format("01-02-2006") + ".log" log.SetOutput(&lumberjack.Logger{ Filename: logFile, MaxSize: 500, // megabytes MaxBackups: 3, MaxAge: 28, //days Compress: true, // disabled by default })

longbozhan commented 2 years ago

a project timewriter impl daily rotate: timewriter @sriram275