lumberjack icon indicating copy to clipboard operation
lumberjack copied to clipboard

Create the file when the file does not exist

Open njuptlzf opened this issue 3 years ago • 3 comments

I realized Lumberjack in the audit module of Kubernetes.

When the file is deleted, it needs to be recreated without restarting the process to ensure that the log is not lost.

njuptlzf avatar Mar 11 '21 10:03 njuptlzf

PTAL @natefinch

njuptlzf avatar Mar 11 '21 10:03 njuptlzf

I don't really want to incur the overhead of doing an os.stat on every single write.

A better way to do this is to handle the error when you try to write to a file that's been deleted. They way the only overhead is when the file is actually missing.

natefinch avatar Mar 11 '21 12:03 natefinch

I don't really want to incur the overhead of doing an os.stat on every single write.

A better way to do this is to handle the error when you try to write to a file that's been deleted. They way the only overhead is when the file is actually missing. This sounds correct. I noticed that many log libraries do not have this kind of log file loss judgment. Can you share your opinion on this? For the time being I only think of goroutine, not sure if lumberjack is needed.

njuptlzf avatar Mar 11 '21 13:03 njuptlzf