natefinch / lumberjack

lumberjack is a log rolling package for Go
MIT License
4.76k stars 585 forks source link

Create the file when the file does not exist #131

Open njuptlzf opened 3 years ago

njuptlzf commented 3 years ago

I realized Lumberjack in the auditmodule 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 commented 3 years ago

PTAL @natefinch

natefinch commented 3 years ago

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.

njuptlzf commented 3 years ago

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.