chemitaxis
chemitaxis

Reputation: 14889

Console.log in a production app using node.js, express and PM2

I'm using console.log for debugging some information in my web app using node.js, expressjs and PM2. All is working fine :)

I want to know if my web app can have performance problems in production if I use console.log this:

var myVariable = "Enter in this section of code";
console.log(myVariable);

I have read about console.log is synchronous and can affect to my performance... if this is real in this moment (I'm using Express 4), how can I remove these console.log in different environments like production?

I'm using PM2 (pm2 logs command) to watch the logs and pm2 flush to clean the logs.

Thanks.

Upvotes: 1

Views: 2117

Answers (1)

cshion
cshion

Reputation: 1213

You could use winston for logging , you could configure transport depending on your env , for example you could use Console and File tranports in development and just File in production. PD: pm2 takes data from std log(console)

Upvotes: 1

Related Questions