Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

winstonDailyRotateFile does not create a new file if existing file is deleted #376

Open
anuragme7 opened this issue Jul 5, 2023 · 2 comments

Comments

@anuragme7
Copy link

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 -

  1. Read winston error log file
  2. Append the file on Cloud
  3. 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.

@rahulpurohitcore
Copy link

I am facing the same issue.

@seidhkona
Copy link

Any updates on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants