I'm trying to find out where PM2 saves the log files by default?
I'm working with a Linux Ubuntu 16.04 server and I've installed it globally with npm i pm2 -g
.
Log files are located in the folder $HOME/. pm2/logs .
Type pm2 log in a shell and you get an overview of the last 15 log lines and the last 15 error lines in realtime. At the top of these log lines, the location of your logfile is shown. You can also type pm2 log --lines 1000 to show more lines, in this case 1000.
Answer. Note: Node. js can also records logs directly into /var/www/vhosts/system/example.com/logs/ directory, but this functionality is a part of Passenger Enterprise which is not included into the free edition that is provided by Plesk.
Monitoring Nodejs Application Using PM2 TerminalTo view logs of an app, first select it (use up/down arrows) from the process list. The terminal-based monitoring only works well for applications running on a single server. To monitor and diagnose cross-server applications, use the PM2 web-based dashboard.
pm2 saves logs to $HOME/.pm2/logs/XXX-err.log
by default, where XXX
is your pm2 app name
I wanted to see the logs for different processes. There is a console-based UI for this:
pm2 monit
Extra tips for pm2 newbies:
pm2 start myApp.js -i max
pm2 start all
(also stop / delete)pm2 list
Type pm2 log
in a shell and you get an overview of the last 15 log lines and the last 15 error lines in realtime. At the top of these log lines, the location of your logfile is shown. You can also type pm2 log --lines 1000
to show more lines, in this case 1000.
$pm2 log
$pm2 log --lines 500
To exit, just type ctrl-c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With