I've been trying to start an express server in pm2 cluster mode. But when I run pm2 logs it does not show any logs produced by the code (console.log or console.error for example).
To illustrate my issue, consider this small snippet of server
const app = require('express')();
app.all('*', (req, res) => {
console.log('new request recieved');
res.send();
});
app.listen(3000);
I've tried everything mentioned in pm2 docs. Even specifying the log files does not work.
This is the command I used
pm2 start -i 0 --merge-logs npm -- start -o /home/user/.pm2/logs/out.log -e /home/user/.pm2/logs/err.log --name playground
Although the logs are written to a file in ~/.pm2/pm2.log, -e and -o option have no effect.
Right now I have to use tail -f ~/.pm2/pm2.log
I want to be able to see logs when I run pm2 log [app name/id] as I'll be running multiple servers in cluster mode and want the logs to be separate for each cluster of server.