Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default location of PM2 log files?

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.

like image 649
JoKeRxbLaCk Avatar asked Apr 24 '19 10:04

JoKeRxbLaCk


People also ask

Where are pm2 logs located?

Log files are located in the folder $HOME/. pm2/logs .

What are 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.

Where is node JS log file?

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.

How do I monitor pm2 logs?

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.


3 Answers

pm2 saves logs to $HOME/.pm2/logs/XXX-err.log by default, where XXX is your pm2 app name

like image 171
varundhariyal Avatar answered Oct 06 '22 11:10

varundhariyal


I wanted to see the logs for different processes. There is a console-based UI for this:

pm2 monit

Extra tips for pm2 newbies:

  • Launch multiple, co-ordinated, instance per cpu core with: pm2 start myApp.js -i max
    • Beware the 'js' example of cluster configuration; it didn't work for me. Try 'json' instead.
  • By default, you need to leave user logged in to keep cluster running
  • Handy commands:
    • pm2 start all (also stop / delete)
    • pm2 list
like image 15
Peter L Avatar answered Oct 06 '22 10:10

Peter L


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

like image 11
Kurt Van den Branden Avatar answered Oct 06 '22 10:10

Kurt Van den Branden