我正在将一个node.js应用程序部署到heroku(雪松堆栈)
我已将 NODE_ENV 设置为如下:
heroku config:add NODE_ENV=production
然后我会这样做:
git push heroku
但是,启动后(我有一个 console.log 生成第一个日志条目),应用程序崩溃了。
我跑:
heroku logs
并出现以下错误。
如何打开它所引用的/app/log/Production.log?
app[web.1]: listening on port 32168 within production environment
app[web.1]:
app[web.1]: events.js:48
app[web.1]: throw arguments[1]; // Unhandled 'error' event
app[web.1]: ^
app[web.1]: Error: ENOENT, open '/app/log/production.log'
heroku[web.1]: Process exited with status 1
heroku[web.1]: State changed from starting to crashed
最佳答案
您收到的错误意味着它正在尝试打开“/app/log/Production.log”,但无法执行此操作。因此,找出尝试记录的位置并禁用或更改它。
根据 Heroku,您应该将应用程序日志发送到 STDOUT:
https://devcenter.heroku.com/articles/logging
所以console.log应该足够了。
关于node.js - Heroku 日志 - 错误消息中提到的打开日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10190213/