-
Notifications
You must be signed in to change notification settings - Fork 639
Open
Description
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:

Metadata
Metadata
Assignees
Labels
No labels