Winston J. My log files do not rotate after exceeding maxsize

I have the following winston configuration:

'use strict' import winston from 'winston' import config from '../../config/environment' export default winston.createLogger({ level: 'info', format: winston.format.printf(info => info.message), transports: [ new winston.transports.Console(), new winston.transports.File({ filename: `${config.logsPath}/express.error.log`, maxsize: 300, level: 'error' }), new winston.transports.File({ filename: `${config.logsPath}/express.log`, maxsize: 300 })] }) 

None of these files rotate after reaching a threshold of 300 bytes.

+5
source share
1 answer

You are using release version 3.0.0 , which has an error in the File transport. In principle, once the maxsize internal variable self.filename not updated over the maxsize threshold, so _createStream reopened the append stream to an existing file and continued to write to it. It works for the first time because self.filename set during initialization from the parameters.

I sent a PR that fixes the problem. In addition, you can return to 2.4.0 if this is not a problem.

+5
source

Source: https://habr.com/ru/post/1272561/


All Articles