如何访问通过 pm2 启动的 Node.js 应用程序日志
How to access a Node.js application log lauched through pm2
我一直在使用 Socket.IO、Express、MySql 和 https 开发一个 Node.js 应用程序,在我使用 pm2 "deamonized" 之前一切正常。现在,我的套接字似乎没有响应,我想调试它。 问题是我似乎无法再从这段代码中找到 console.log() 函数输出其文本的位置。
如果你想知道,我所有的 pm2 进程都是在线的,我可以从客户端刷新我的页面。但是服务器上应该有一个功能,当数据库中发生某些事情但没有发生时,会在客户端触发一个事件。
可以告诉我 consone.log() 的输出在哪里吗?
来自 PM2 文档:
PM2 allows you to easily manage your application’s logs. You can
display the logs coming from all your applications in real-time, flush
them, and reload them. There are also different ways to configure how
PM2 will handle your logs (separated in different files, merged, with
timestamp…) without modifying anything in your code.
http://pm2.keymetrics.io/docs/usage/log-management/
以及其他 SO 问题:
您可以使用 pm2 logs
命令访问日志
http://pm2.keymetrics.io/docs/usage/log-management/
问题是当您的服务器 运行ning 并且您使用
pm2 log
将显示除
之外的所有日志
console.log()
您所要做的就是代替 pm2 日志,运行
pm2 logs
注意日志中的“s”。希望这有帮助
我一直在使用 Socket.IO、Express、MySql 和 https 开发一个 Node.js 应用程序,在我使用 pm2 "deamonized" 之前一切正常。现在,我的套接字似乎没有响应,我想调试它。 问题是我似乎无法再从这段代码中找到 console.log() 函数输出其文本的位置。
如果你想知道,我所有的 pm2 进程都是在线的,我可以从客户端刷新我的页面。但是服务器上应该有一个功能,当数据库中发生某些事情但没有发生时,会在客户端触发一个事件。
可以告诉我 consone.log() 的输出在哪里吗?
来自 PM2 文档:
PM2 allows you to easily manage your application’s logs. You can display the logs coming from all your applications in real-time, flush them, and reload them. There are also different ways to configure how PM2 will handle your logs (separated in different files, merged, with timestamp…) without modifying anything in your code.
http://pm2.keymetrics.io/docs/usage/log-management/
以及其他 SO 问题:
您可以使用 pm2 logs
命令访问日志
http://pm2.keymetrics.io/docs/usage/log-management/
问题是当您的服务器 运行ning 并且您使用
pm2 log
将显示除
之外的所有日志console.log()
您所要做的就是代替 pm2 日志,运行
pm2 logs
注意日志中的“s”。希望这有帮助