How to add dates to pm2 error logs?

As per the pm2 logs official documentation, you can use --time, which prefixes logs with a standard formatted timestamp.

pm2 start app.js --time 

If you have already created the app, you can update it while restarting the application with:

pm2 restart 0 --time

Make sure to pm2 save afterwards.

Note that you can also use a custom formatter as per this issue & this commit:

pm2 start app.js --log-date-format 'DD-MM HH:mm:ss.SSS'

where 'DD-MM HH:mm:ss.SSS' is any momentjs valid format.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)