PM2 pile up tones of log file into disk server, how to solve it.

 [pm2 flush] this command will remove all previous logs and cleanup your disk space but make sure in production you won’t need those logs.


Also you can make sure that logs won't pile up that much using the following library.


pm2 install pm2-logrotate

NOTE: the command is pm2 install NOT npm install

Run the following command after installed the module: pm2 set pm2-logrotate:<param> <value>


Example


pm2 set pm2-logrotate:max_size 1G (1GB)

pm2 set pm2-logrotate:compress true (compress logs when rotated)

pm2 set pm2-logrotate:rotateInterval '*/1 * * * *' (force rotate every minute)


Post a Comment

0 Comments