如何在 Heroku 上显示 console.log()?

Kei*_*Kei 5 javascript heroku node.js heroku-toolbelt console.log

我尝试通过在 Node.js 中使用 console.log() 来调试我的应用程序。

但是,无论它们显示多少行,我都永远无法在 heroku 日志中看到它们。

$ heroku logs -n 200
Run Code Online (Sandbox Code Playgroud)

这对我不起作用。

每当我在 Heroku 服务器上发布内容时,日志只显示如下内容:

2018-09-10T02:14:12.731148+00:00 heroku[router]: at=info method=POST path="/users" host=obscure-journey-65698.herokuapp.com request_id=349a44e8-5fd7-46a2-aacb-75e51503109c fwd="73.67.204.217" dyno=web.1 connect=1ms service=355ms status=400 bytes=216 protocol=https
Run Code Online (Sandbox Code Playgroud)

控制台日志永远不会显示!他们在运行 npm start 时确实记录了我想要的信息。

谢谢你的帮助。

Adi*_*dil 4

转到 heroku 网站并打开您部署的应用程序。转到右上角的“更多”选项卡并打开日志。在日志选项卡中,您将看到控制台输出。您将看到写入 procfile 中的文件或第一个执行的文件的控制台输出。例如,如果在 procfile 中写入:web: node server.js那么 server.js 文件将是第一个执行的文件。因此,如果我在 server.js 文件中写入了 console.log("output") ,那么输出将显示在 heroku 的日志中,该日志位于如上所述的“更多”选项卡中。谢谢