winstonDailyRotateFile does not create a new file if existing file is deleted
anuragme7 opened this issue · 2 comments
Versions
winston - 2.4.0
winston-daily-rotate-file - 1.7.2
Code looks like following -
---------------------Code in app.js-------------------------------------
let transportDailyRotateError = new winstonDailyRotateFile({
name : 'errorLogs',
filename: './logs/application_,
datePattern: 'yyyy-MM-dd.log',
prepend: false,
level: 'error',
maxFiles: 30
});
let trasportConsole = new (winston.transports.Console)({
timestamp: logDTFormat,
colorize: true,
level: levelLog
});
let winstonTransports = [];
winstonTransports.push(transportDailyRotateError);
winstonTransports.push(trasportConsole);
winston.configure({
level: levelLog,
transports: winstonTransports
});
--------------------------Logger to log errors--------------------------------
const logger = require('winston');
function xyz() {
...Do something....
if (err) logger.error('Error encountered', err)
}
I am creating a service to upload file on Cloud every 10 minutes. The logic works like following -
- Read winston error log file
- Append the file on Cloud
- Delete winston error log file
In my example application_2023-07-05.log file once created is being read and uploaded on cloud properly, but once I delete the log file, my future logs are not being recorded in a new file. Meaning once the log file application_2023-07-05.log is deleted, new file is not being created with same name after 10 minutes, whereas the logs gets lost.
How can I keep creating new files so that I can append as new data is populated in the error logs? please help.
I am facing the same issue.
Any updates on this issue?