I noticed that when we call wrirte function, we will run code: https://github.com/natefinch/lumberjack/blob/v2.0/lumberjack.go#L135
when it need to run rotate, it will call file close. from the code of close(), it will only close file once. l.file will be nil whether the file closed success or not.
// close closes the file if it is open.
func (l *Logger) close() error {
if l.file == nil {
return nil
}
**err := l.file.Close()**
l.file = nil
return err
}
So if file.Close() return error, the process will have no chance to release this fd. when we try to write file, the code will be exectuted which will create a new file:
if l.file == nil {
if err = l.openExistingOrNew(len(p)); err != nil {
return 0, err
}
}
there is a online case:

I noticed that when we call wrirte function, we will run code: https://github.com/natefinch/lumberjack/blob/v2.0/lumberjack.go#L135
when it need to run rotate, it will call file close. from the code of close(), it will only close file once. l.file will be nil whether the file closed success or not.
So if file.Close() return error, the process will have no chance to release this fd. when we try to write file, the code will be exectuted which will create a new file:
there is a online case: