uber-go / zap

Blazing fast, structured, leveled logging in Go.
https://pkg.go.dev/go.uber.org/zap
MIT License
22.08k stars 1.44k forks source link

Unable to delete the log file used by zap. #1469

Open charankamarapu opened 1 week ago

charankamarapu commented 1 week ago

Describe the bug I have add a file to the development config like this -

LogCfg.OutputPaths = []string{
        "stdout",
        "./logs.txt",
}

and then created a logger withlogCfg.build() and later while exiting my application I wanted to delete that file but it throws an error saying file is being used by another process(windows) most probably it is being used by the logger. I was creating the file to upload the logs to somewhere and once app is about to exit I want to delete it. How can I do it? I even tried assigning nil to logger before deleting the file.

To Reproduce You can just create a simple logger and try to delete the log file.

Expected behavior File should get deleted.