winstonjs / winston-daily-rotate-file

A transport for winston which logs to a rotating file each day.
MIT License
899 stars 156 forks source link

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

Open anuragme7 opened 1 year ago

anuragme7 commented 1 year ago

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 commented 8 months ago

I am facing the same issue.

seidhkona commented 7 months ago

Any updates on this issue?