一般情况下,pm2启动的nodejs中console.log出来的内容都会以标准流的方式输出到屏幕上。
查看方式:
1,直接运行 pm2 logs,此时屏幕上会同时输出error log和 实时log, 同时会打印出日志文件的路径, 类似:
root@xxxxxxx:~# pm2 logs
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
/root/.pm2/pm2.log last 15 lines:
/root/.pm2/logs/start-error.log last 15 lines:
/root/.pm2/logs/start-out.log last 15 lines:
2,直接tail -f 对应的文件即可: tail -f /root/.pm2/logs/start-out.log
root@xxxxxxxx:~# tail -f /root/.pm2/logs/start-out.log