12

Is there a way to tell pm2 to leave stderr and stdout alone (as opposed to writing to files)?

I'm using pm2 on Heroku using this gist as my model. Everything seems to work perfectly except that I've lost any ability to log from within my app. They don't show up in the Heroku logs and the files that pm2 creates aren't accessible to me on Heroku's file system (or I can't find them).

uooq
  • 911
  • 8
  • 12

2 Answers2

16

In your package.json:

"scripts": {
  "preinstall": "npm i -g pm2 && pm2 install pm2-logrotate"
}

In your Procfile:

web: pm2 start app.js && pm2 logs all
Liko
  • 2,130
  • 19
  • 20
3

We just created the official PM2 documentation, here is how to integrate PM2 with Heroku while printing the logs:

http://pm2.keymetrics.io/docs/usage/use-pm2-with-cloud-providers/#heroku-google-app-engine-azure

Alex

Unitech
  • 5,781
  • 5
  • 40
  • 47
  • Unfortunately, this guide doesn't tell the most important info — **pm2** must be installed globally and for a proper logging `pm2-logrotate` is required. The bottom line, Liko's answer solves the issue, while **pm2**'s documentation doesn't! – Mike Jun 24 '21 at 16:41
  • @Mike wow really , thank God for your answer, i was about to try PM2 docs – Nathaniel Babalola Sep 20 '21 at 22:06