Dave
Dave

Reputation: 2180

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.

Upvotes: 77

Views: 187393

Answers (6)

Rajib
Rajib

Reputation: 592

pm2 status

it will show your apps name or id say above command return apps name PN and id : 0 Then you can write following command in console

pm2 describe 0

Or

pm2 describe 

In return you will see 2 tables where you can see as below

| script path       │ /root/.nvm/versions/node/v7.3.1/bin/npm           │
│ script args       │ --prefix /opt/da/pn run start │
│ error log path    │ /root/.pm2/logs/pn-node-error-0.log       │
│ out log path      │ /root/.pm2/logs/pn-node-out-0.log      

You are actually looking for out log path. error log path will be shown if you configured

Upvotes: 5

jed
jed

Reputation: 399

pm2 has two types of log files for every app that it runs, an error log file and an out log file.

The error logs are saved to $HOME/.pm2/logs/XXX-error.log or ~/.pm2/logs/XXX-error.log

While the out logs are saved to $HOME/.pm2/logs/XXX-out.log or ~/.pm2/logs/XXX-access.log.

Where XXX is the name of your app.

Upvotes: 8

sday
sday

Reputation: 1051

A great way to get information on logfile location (and other useful info) is to do a "pm2 describe" on the process that you have running. You can use this method running pm2 as a standard user or if you use it as sudo pm2.

Get the name or id of the process

pm2 list

use describe by either using the id# or the name

pm2 describe 0

Upvotes: 11

Kurt Van den Branden
Kurt Van den Branden

Reputation: 12934

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

Upvotes: 18

Peter L
Peter L

Reputation: 3343

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

Upvotes: 30

varundhariyal
varundhariyal

Reputation: 1915

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

Upvotes: 116

Related Questions