Module to rotate logs of every pm2 application. With some extended features.
npm install pm2-logrotate-extforced which specifies if logs should be rotated every time on rotateInterval cron.
pm2 install NOT npm install
max_size (Defaults to 10M): When a file size becomes higher than this value it will rotate it (its possible that
10G, 10M, 10K
retain (Defaults to 30 file logs): This number is the number of rotated logs that are keep at any one time, it
compress (Defaults to false): Enable compression via gzip for all rotated logs
dateFormat (Defaults to YYYY-MM-DD_HH-mm-ss) : Format of the data used the name the file of log
rotateModule (Defaults to true) : Rotate the log of pm2's module like other apps
workerInterval (Defaults to 30 in secs) : You can control at which interval the worker is checking the log's
1)
rotateInterval (Defaults to 0 0 * everyday at midnight): This cron is used to a force rotate when executed.
TZ (Defaults to system time): This is the
Etc/GMT+1, with an hourly log, will save a file at hour 14 GMT with
13 (GMT+1) in the log name.
forced (Defaults to true): Enable or disable forced rotation on rotateInterval, if set to false, rotation of the
max_size limit is reached.
┬ ┬ ┬ ┬ ┬ ┬
│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)
│ │ │ └────────── day of month (1 - 31)
│ │ └─────────────── hour (0 - 23)
│ └──────────────────── minute (0 - 59)
└───────────────────────── second (0 - 59, OPTIONAL)
`
$3
After having installed the module, you have to type :
pm2 conf
$3
After having installed the module you have to type :
pm2 set pm2-logrotate-ext:
e.g:
- pm2 set pm2-logrotate-ext:max_size 1K (1KB)
- pm2 set pm2-logrotate-ext:compress true (compress logs when rotated)
- pm2 set pm2-logrotate-ext:rotateInterval '/1 *'` (force rotate every minute)