lumberjack
lumberjack copied to clipboard
zap-logger with lumberjack not working
I test in windows environment Integration tests for zap logger and lumberjack-rolling find not working, no rotation
func WithFileRotationP(file string) Option {
dir := filepath.Dir(file)
if err := os.MkdirAll(dir, 0766); err != nil {
panic(err)
}
return func(opt *option) {
opt.file = &lumberjack.Logger{
Filename: file,
MaxSize: 1,
MaxBackups: 300,
MaxAge: 30,
LocalTime: true,
Compress: true,
}
}
}
output error:
2023-03-30 17:24:24.6335537 +0800 CST m=+3.052071301 write error: can't rename log file: rename ./test.log test-2023-03-30T17-24-24.633.log: The process cannot access the file because it is being used by another process.
When I switch to linux environment, it works fine
I suspect this bug is because on Linux it's fine to rename a file even if it's in use, but not on Windows.