Rotate a log similar to the way linux logrotate does, appending and updating
.NUM
indexes as you go.
var rotate = require('log-rotate');
// move a log file while incrementing existing indexed / rotated logs
rotate('./test.log', function(err) {
// ls ./ => test.log test.log.0
});
Limit the number of rotated files to count
var rotate = require('log-rotate');
rotate('./test.log', { count: 3 }, function(err) {
// ls ./ => test.log test.log.0 test.log.1
});
Compress rotated files with gzip
With npm do:
npm install log-rotate