1

I've been developing a Node.js application using Socket.IO, Express, MySql and https and everything worked fine until I "deamonized" it with pm2. Now, my socket seems somehow unresponsive and I'd like to debug it. The problem is that I can't seem to find where the console.log() function from this code outputs its text anymore.

I case you'd like to know, all my pm2 processes are online and I can refresh my pages from the client side. But there should be a fonction on the server that triggers an event on the client side when something happens in the database and it does not.

Could tell me where the output from consone.log() is goes?

Frank Malenfant
  • 126
  • 1
  • 11

3 Answers3

4

You can access the logs with the pm2 logs command http://pm2.keymetrics.io/docs/usage/log-management/

AJ Funk
  • 3,099
  • 1
  • 16
  • 18
2

the problem is that while your server is running and you use

pm2 log

all logs will be displayed except

console.log()

all you have to do is instead of pm2 log, run

 pm2 logs

note the "s" at the logs. hope this helps

Chukwuemeka Maduekwe
  • 6,687
  • 5
  • 44
  • 67
1

From PM2 docs:

PM2 allows you to easily manage your application’s logs. You can display the logs coming from all your applications in real-time, flush them, and reload them. There are also different ways to configure how PM2 will handle your logs (separated in different files, merged, with timestamp…) without modifying anything in your code.

http://pm2.keymetrics.io/docs/usage/log-management/

And other SO question:

Make pm2 log to console

Community
  • 1
  • 1
noderman
  • 1,934
  • 1
  • 20
  • 36
  • I have already tried *pm2 flush* and then *pm2 logs * but nothing shows on the log when I connect a new client even though i have a console.log() function called everytime a new client connects. – Frank Malenfant Mar 23 '17 at 20:05
  • It seems that I had that EADDRINUSE problem again so I had to kill a process and then start only one process not to get the WebSocket error. After that *pm2 logs * finally showed me what I expected. The problem was elsewhere. Thanks. – Frank Malenfant Mar 23 '17 at 20:18