Rails 3.2.1 在 Passenger、Thin 或 Unicorn 中进行日志记录
我已经为我的 Rails 应用程序尝试了这 3 种托管方法,无论我做什么,当我在生产环境中运行时,我都无法获得一致的日志记录。
对于我的测试,我创建了一个空白应用程序并尝试访问根目录。然后我会添加一个用户脚手架并整理数据库。
如果我将 RAILS_ENV 转向开发,则 log/devlopment.log 工作得很好,记录我期望的所有内容。
当我将 RAILS_ENV 切换到生产环境时,log/Production.log 以一种奇怪的方式记录。在 Passenger 中,我遇到第一个路由错误。然后什么也没有。当我重新启动 apache 或 nginx 时,我会得到自第一个(记录的)错误以来引起的所有路由错误,然后日志将无法写入任何新内容,直到我重新启动底层服务器。如果我遇到配置问题,apache2/error.log 将被记录。然后它只记录缓存未命中
使用 Thin 和 Unicorn,我只收到有关静态资产的错误(我没有预编译资产)。一旦我预编译了资产,就不再出现日志消息。
在所有 3 个设置中,我都会在 production.log 中收到预编译消息(当我运行 asset:precompile 时)(表明 Rails 至少可以写入日志)。
是否有人拥有在部署 gem(Passenger、Thin 或 Unicorn)之一上运行的 Rails 3.2.1 应用程序,并且在生产模式下正确记录?我花了 5 天的时间来处理这个问题。我没主意了。
I've tried those 3 hosting approaches for my Rails app, and no matter what I do, I can't get consistant logging when I run in the production environment.
For my tests, I created a blank app and tried to access the root directory. I would then add a users scaffold and rake the database.
If I turn RAILS_ENV to development, the log/devlopment.log works just fine, logging everything that I would expect.
When I turn RAILS_ENV to production, the log/production.log logs in a strange manner. In Passenger, I get the first routing error. Then nothing. When I restarted apache or nginx, I would get all the routing errors that I had caused since the first (logged) one, then the log would fail to write anything new until I restarted the underlying server. apache2/error.log would get logged to if I had a configuration issue. Then it only logged cache misses
With Thin and Unicorn, I only get errors about the static assets (I did not precompile the assets). Once I precompiled the assets, no more log messages appeared.
On all 3 setups, I would get precompilation messages (when I ran assets:precompile) in production.log (indicating that Rails could at least write to the log).
Does anyone have a Rails 3.2.1 app that is running on one of the deployment gems (Passenger, Thin, or Unicorn), that is logging correctly in production mode? I've spent 5 days working on this. I'm out of ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
结果发现这是 Rails 3.2.x 中报告的问题。修复程序已提交,有望与 Rails 3.2.2 一起发布。
https://github.com/rails/rails/issues/4277
Turns out its a reported issue in Rails 3.2.x. A fix has been submitted and will hopefully be released with Rails 3.2.2.
https://github.com/rails/rails/issues/4277