winston.add(winston.transports.File, { filename: 'log.txt' });
How to specify a rewrite file option, not append?
Easiest is to remove the log file before you initiate your logger on each run. You can do this with the fs.unlink or fs.unlinkSync methods.
The File transports accepts flags in an options param. For [email protected]:
winston.add(new winston.transports.File, {
filename: 'your-file.log',
options: { flags: 'w' }
});
See fs.open docs for what flags are available in Node.js.
Most helpful comment
The
Filetransports acceptsflagsin an options param. For[email protected]:See
fs.opendocs for what flags are available in Node.js.