Is there a way to add timestamps to error logs in .pm2/logs?
I noticed that pm2 logs
command shows aggregated logs with timestamps, but looking into log files - there are only messages and stacktraces without dates.
As per this issue & this commit, you can use:
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.
As per the pm2 logs official documentation, now you can use the simpler --time
, like:
pm2 start app.js --time
where --time
prefixs logs with standard formatted timestamp.
it appears that if you set
--watch
to look for changes you may lose the log-date-format on app reload, getting you back to logging without date:pm2 start app.js --log-date-format 'DD-MM HH:mm:ss.SSS' --watch
. I just noticed that on my development machine. LE corrected: only thepm2 logs
command will skip showing date/time on app refresh.Hello, this dose not work for me.I'm using pm2 to manage python script,could you tell me what's the problem? TXU.
Is there some way to only timestamp the error log and not the standard console log? I am already time stamping everything that goes to console.log.