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 this files are rotating after they reach the 300 bytes threshold.
You are using the version 3.0.0
release candidate which has a bug in its File
transport. Basically, once over the maxsize
threshold, internal self.filename
variable was not being updated so _createStream
would re-open the append stream to the existing file and continue writing to it. It works the first time around because self.filename
is set when initializing from options.
I've submitted a PR which fixes the issue. Alternatively, you can revert to 2.4.0
where this isn't an issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With