winstonjs / winston-daily-rotate-file

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

watchLog only works at the first time when file is deleted. #348

Open nfer opened 2 years ago

nfer commented 2 years ago

This is a showcase:

var winston = require('winston');
var DailyRotateFile = require('winston-daily-rotate-file');

var transport = new DailyRotateFile({
  filename: 'application-%DATE%.log',
  datePattern: 'YYYY-MM-DD-HH',
  watchLog: true,
});

transport.on('new', function(newFile) {
  console.log('new', newFile)
});

var logger = winston.createLogger({
  transports: [
    transport
  ]
});

setInterval(() => {
  console.log('hello')
  logger.info(`Hello World!: ${new Date()}`);
}, 500);

After the second delete file by rm application-*.log, the winston-daily-rotate-file not auto create the log file. While the first delete file works, it auto create the log file.

wbt commented 2 years ago

I don't completely understand the actual steps being followed, the actual results, and the expected results. Could you elaborate on those?

mrfossel commented 1 year ago

@nfer Any luck with this? I am having the same issue.