nodejs logging

This is a quick and dirty way to cleanup logging in nodejs, this is particularly useful when running pm2 and the programmer is using console.log to debug their code and hasn’t cleaned it up, if pm2 is logging by default your disk could fill up.

Add the below line to your code to send console.log nowhere

//Disable all logging
console.log = function() {}

With regards to pm2, by default the logs are in ~/.pm2/logs

#nodejs #pm2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s