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
.
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
.
pm2 saves logs to $HOME/.pm2/logs/XXX-err.log
by default, where XXX
is your pm2 app name
pm2 start api --time
and then pm2 logs api --format
and no logs are displaying on screen –
Hegel pm2 start api --time
and then pm2 logs api
. now i can see the time prefixing the logs. thank you again! –
Hegel ~/.pm2/logs/xxx.err.log
only shows 500 status but doesn't show error –
Inflorescence 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
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
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.
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
© 2022 - 2025 — McMap. All rights reserved.