I am running a node webserver using pm2. Since pm2 spawns another process and redirects stdout and stderr to files, I have to look somewhere else for the logs. Ideally, I would like to have the node process output to the same console window that I've run pm2 from. Otherwise, I would settle for pm2 run the node process with an active console window and have stdout and stderr of the node process write to that console window. How can this be achieved? I'm on a windows machine.
Application Logs Once an application is started with PM2 you can consult and manage logs easily. Log files are located in the folder $HOME/. pm2/logs .
By default, all logs are saved into $HOME/. pm2/logs .
You can put console logs but just remember to restart the server. Hot reload does not detect changes in dist folders of libraries in node_modules.
I believe you can also see the stdout and stderr of a process that is running daemonized by the command pm2 logs
or pm2 logs [app-name]
.
you can easily achieve that by starting another terminal/console and run this command
pm2 log
logs everything to the terminal except console.log
pm2 logs
logs everything to the terminal and console.log
notice the 's' in the second command
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