Reputation: 221
Is is possible to set the age of the logfile when using file-transport for winston. Can we set the age/time for the file "server.log" to 24hours, so it get auto deleted after 24hours and a new file with the same name get created, thereby saving memory?
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename: 'logs/server.log',handleExceptions: true }),
});
Upvotes: 0
Views: 976
Reputation: 473
The DailyRotateFile transport will let you set a time when a new log file is created. You can then delete old ones with a cron job.
Upvotes: 1
Reputation: 7334
As far as I know, Winston doesn't support that.
These kind of problems are normally solved by rotating your logs (writing to a new file every day, eg: log_2015-02-23.txt
, log_2015-02-24.txt
, etc) and then deleting obsolete ones with a cron job, like in this example.
Upvotes: 0