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

Rotating file stream not working if maxsize = 1kb or frequency is 1 minute. Does this library really works #387

Open mai1x9 opened 7 months ago

mai1x9 commented 7 months ago
  level: 'info',
  filename: 'application-%DATE%.log',
//   datePattern: 'YYYY-MM-DD-HH',
    frequency: '1m',
  zippedArchive: true,
  maxSize: '1kb',
  maxFiles: '14d'
});

As expected even if size of log is > 1kb it is not rotated. Even freqeuncy is not working .

mdk000 commented 6 months ago

@mai1x9 try to disable archiving as @hyavari suggested in https://github.com/winstonjs/winston-daily-rotate-file/issues/380#issuecomment-1885516202.

Archiving and deleting at the same time doesn't make sense :)

xnubber commented 2 months ago

@mai1x9

the situation below will work

// frequency work
const transport = new winston.transports.DailyRotateFile({
  filename: application-%DATE%.log,
  datePattern: 'YYYY-MM-DD_HH-mm-ss',
  frequency: '3600s',
  zippedArchive: true,
  maxSize: '30k',
  maxFiles: '14d'
});

but this won't

// frequency not work
const transport = new winston.transports.DailyRotateFile({
  filename: application-%DATE%.log,
  datePattern: 'YYYY-MM-DD_HH-mm-ss',
  frequency: '1h',
  zippedArchive: true,
  maxSize: '30k',
  maxFiles: '14d'
});

and if log file reaches maxSize , after archived , the new log filename will be exactly "application-%DATE%.log"... so weird ...

on the other hand, the maxSize should be "1k" not "1kb"