You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rotate_ method when rotating logs uses std::rename, which cannot rename a file if it has multiple owners. We try to rename the files 2 times, if we fail, then we overwrite the log file and lose the old information. I suggest that 2 solutions:
(OK) Disable inheritance of the log file descriptor. Sometimes you need to allow inheritance of descriptors in the CreateProcess function, in which case inheritance of the log file descriptor ruins everything, rotation does not work.
(NOT WELL) If for some reason we cannot disable file descriptor inheritance (I didn’t look at this point in the code), then we can do this: if renaming fails, create a new file and copy the data into it, overwriting the current file. This may take time, but we already spend 100ms when rename fails. One could set this as an option when using the logger.
The text was updated successfully, but these errors were encountered:
Linked issue(closed): #2347
The rotate_ method when rotating logs uses std::rename, which cannot rename a file if it has multiple owners. We try to rename the files 2 times, if we fail, then we overwrite the log file and lose the old information. I suggest that 2 solutions:
The text was updated successfully, but these errors were encountered: