Frank Malenfant
Frank Malenfant

Reputation: 146

How to access a Node.js application log lauched through pm2

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?

Upvotes: 2

Views: 7893

Answers (3)

Chukwuemeka Maduekwe
Chukwuemeka Maduekwe

Reputation: 8566

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

Upvotes: 2

AJ Funk
AJ Funk

Reputation: 3187

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

Upvotes: 4

noderman
noderman

Reputation: 1944

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

Upvotes: 1

Related Questions