一般情况下,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
本文介绍了使用PM2启动Node.js应用时如何查看console.log输出的日志。可以通过运行pm2logs命令来显示最近的日志,或者使用tail -f命令跟踪特定的日志文件。
8439

被折叠的 条评论
为什么被折叠?



