winston: Winston Transport File - zippedArchive option doesn't work correctly

If you use the following transport file:

new (winston.transports.File)({
          level: 'silly',
          filename: './test.log',
          maxsize: 500000,
          maxFiles: 4,
          format: format.combine(
            format.splat(),
            format.label({ label: 'test' }),
            format.timestamp(),
            format.prettyPrint(),
            format.printf( log => {
              return '[ ' + log.timestamp + ' ][ ' + log.level + ' ][ '+ log.label + ' ] ' + log.message;
            })
          ), tailable: true,
          zippedArchive: true,
          exitOnError: false
        }) );

The resulting “test.log” is zipped.

This is wrong since the documentation tells that:

zippedArchive: If true, all log files but the current one will be zipped.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 18
  • Comments: 33 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@DABH I have the same issue too, I also upgraded my Winston version to latest version (3.2.1) but still no success. when the zippedArchive is true , the logger only rename the extension of file so the zip file is corrupted.

Still happening on 3.3.3 😔

@masoudltf: you are right, the latest winston (3.1.0) doesn’t zip any file but only adds the .gz extension. Infact, it seems there is no method which inflates the logs, only the Zlib instance

+1 zippedArchive option on winston.transports.File is broken - resulting files have .gz suffix, but are corrupted.

winston version 3.2.1

The problem persists in version 3.8.1.

i have same issue, only “.gz” appends to the filename and not correctly gzipped.

Done — thank you so much for being willing to take this on!!

Hi @DABH , I would like to give it a try. Please assign it to me.

I have the same issue with 3.0.0.

    new winston.transports.File({
      level: 'info',
      filename: LOGS_PATH,
      handleExceptions: true,
      maxsize: MAX_LOG_SIZE,
      timestamp: true,
      maxFiles: 5,
      eol: '\r\n',
      prettyPrint: true,
      zippedArchive: true
    })

This results in the latest file being gzipped. In 2.4.2, all but the latest file were zipped.