Open Vishal8523 opened 2 years ago
At first glance, it looks like the file may have been locked by some process (e.g. an automated backup) at the time the deletion was attempted.
How to avoid this situation and have proper rotation/deletion of logs ? Considering multiple node processes are writing to the same log file
Note: Also tried removing the file manually from the audit.json but the file gets deleted.
Why do you have multiple Node processes writing to the same log file? You could consider having separate processes log into separate log directories and disabling automated lockers (e.g. backup processes) if you want to increase the probability of correct rotation/deletion of logs.
It is required by the application to log only 1 file from all the Node processes. So, no much control over it. How does one disable automated lockers ?
The automated locking is a file-system feature. What would you expect the result to be if one process tried to write to a file while another process tried to delete it at the same time? That "requirement" as stated seems inconsistent with your use of file rotation, which is going to have multiple files. You may want to consider more deeply what the source/reasoning of that might be - maybe have different processes log to different directories and something else that can read from different directories/streams to present a merged view, or coordinate logging through a single process.
Versions: winston: ^2.4.5 winston-daily-rotate-file: ^3.10.0 Node JS: v12.22.0 OS: Debian 11 Bullseye
During the logs rotate mechanism, some of the files are not deleted from the logs directory. Upon investigation, it is found that the -audit.json file has missing files that made it to not get deleted.
Winston Settings:
The audit.json file is as on 18th Oct 2022. Here, the 17th Oct 2022 file is missing in the audit.json file and this file (Logs-2022-10-17.log) was not deleted from the logs directory.
Requesting a resolution on the issue.