1

I'm implementing logging for a node app and need some advice: I've read some stuff about winston.transports.DailyRotateFile but I still don't get, where can I configure, how much daily log files should it keep. Where can I set it? Also, where do I configure it to compress old logs?

tristantzara
  • 5,597
  • 6
  • 26
  • 40

1 Answers1

2

You should use the following two options:

  • zippedArchive
  • maxFiles

Example:

new (winston.transports.DailyRotateFile)({
  level: process.env.LOG_LEVEL || 'error',
  name: 'log.all',
  colorize: false,
  timestamp: true,
  json: false,
  filename: `logs/famitsu-server`,
  datePattern: '.yyyy-MM-dd.log',
  zippedArchive: true,
  maxFiles: 10,
}),
Gergo
  • 2,190
  • 22
  • 24