Closed pims closed 4 years ago
The point of lumberjack is to rotate logs, if you don't need rotation, don't use lumberjack, or make it optional to use lumberjack in your codebase.
@xiegeo that's fair. I was hoping to find an alternative to removing lumberjack from github.com/kubernetes/kubernetes by having a disable rotation flag, but as you pointed out, it's better to make it optional.
In some environments, it might be advisable to disable log rotation and let another process handle that work.
I originally thought that setting
MaxSize: 0
would disable log rotation, but thefunc (l *Logger) max()
function returns thedefaultMaxSize
:to preserve existing behavior, would you be open to adding a
disableFileRotation
field to theLogger
struct and replacing the various:with:
This should be backward compatible behavior, since the default value for
disableFileRotation
would befalse
and only interested parties would set it totrue
.Another alternative would be to set
MaxSize
to-1
and change behavior accordingly, but many consumer of lumberjack already error on negative values.