#1469·zap

Unable to delete the log file used by zap.

Author: charankamarapuCreated Nov 15, 2024Updated Jun 19, 2025

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 with logCfg.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.