I'm using WinstonJS for logging to a file, and nodemon
to restart when I update my code.
var winston = require('winston');
var logger = new (winston.Logger)({
transports: [
new (winston.transports.File)({
level: 'silly',
filename: __dirname + '/logs/test.log',
json: false
})
]
});
logger.log('info', 'something');
The log file is being appended to, however when I make a code change and save my file, nodemon
runs it again and the log file is appended to again. This leads to a log file that just keeps getting longer and longer, and I have to keep manually deleting the contents.
I guess I could do something with the fs
module, but it would be far nicer to use Winston to say something like update: replace|append
, but I can't see anything like that available.
Is there any way to clear the log file, so I only have log entries for the last time my code was run..?