Facebook Pixel

How do I prevent PM2 logs from filling up disk?

Install pm2-logrotate with pm2 install pm2-logrotate. Configure max file size (pm2 set pm2-logrotate:max_size 5M), retention (pm2 set pm2-logrotate:retain 7), and compression (pm2 set pm2-logrotate:compress true).

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Monitoring and Logging on EC2 Keeping Your Node.js App Healthy in Production

Use pm2 monit for real-time CPU/memory monitoring, pm2 logs for streaming logs, pm2 status for process status. For external monitoring, use UptimeRobot for uptime checks and Sentry for error tracking. Set up a /health endpoint for health checks.

A 200 status with JSON containing status: 'ok', uptime, timestamp, and environment. It should not require authentication, should be fast (no database queries), and should be accessible at /api/health for external monitoring tools.

Install @sentry/node, initialize with your DSN in app.js, and add Sentry.Handlers.errorHandler() before your global error handler. Sentry captures unhandled errors, sends alerts, and provides a dashboard for tracking issues.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.