Search code examples
node.jswinston

How to make archive of log files created by winston in nodejs?


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

var customLevels = {
  levels: {
    debug: 3,
    info: 2,
    warn: 1,
    error:0 
  },
  colors: {
    debug: 'blue',
    info: 'green',
    warn: 'yellow',
    error: 'red'
  }
};

var logger = new (winston.Logger)({
  transports: [
new (winston.transports.Console)(),
new (winston.transports.DailyRotateFile)({
      filename: '../app/log',
      datePattern: 'yyyy-MM-dd.',
      prepend: true,
      maxsize:100000,
      zippedArchive:true,
      maxfile: 5, 
    }),
  ]
});

module.exports = logger;

This is my code it is creating a new log file after exceeding the maximum size and on daily basis. But, after exceeding it is compressing that file. I want compression of the file but not for a single I gave maxfile as 5 as I want an archive of 5 log files but, it's not working for that so any guidance or suggestion is helpful. Thank you


Solution

  • We can not create a single archive of all archive logfiles generated by winston. This functionality is not there in the winston.