生产环境中的 Rails 日志记录

发布于 2025-01-04 21:03:55 字数 346 浏览 2 评论 0 原文

我应该在 Rails 3.2 的默认生产环境中的 production.log 中看到什么样的信息?

我正在运行 Passenger 并尝试访问虚构的控制器名称和无效参数,但在 production.log 中没有显示任何内容。

我尝试在环境/生产.rb 中将记录器级别设置为调试,但该日志仍然为空。

谢谢

编辑

这里有关于冲洗问题的更多信息:

https://github.com/rails/rails/问题/4277

What kind of information should I expect to see in production.log from a default production environment in rails 3.2?

I'm running Passenger and have tried accessing made up controller names and invalid parameters, but nothing is showing up in production.log.

I tried setting the logger level to debug in environments/production.rb, but that log is still blank.

Thanks

Edit

Here's more info on the flushing issue:

https://github.com/rails/rails/issues/4277

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海的爱人是光 2025-01-11 21:03:56

似乎是因为日志文件刷新。默认情况下,rails 不会刷新生产环境中的每个写入日志。

这个拉取请求修复了它,并且在rails HEAD中你可以尝试

config.autoflush_log = true

Seems like it's because of logfile flushing. By default rails not flushing every write to log in production environment.

This pull request fix it, and in rails HEAD you can try

config.autoflush_log = true
我很坚强 2025-01-11 21:03:56

您可能需要通过创建初始值设定项将 Rails.logger 设置为 ActiveSupport::Logger

通过 Rails.logger 检查该值,如果它显示 将其更改为活动支持。

config/initializer/logger.rb 

Rails.logger = ActiveSupport::Logger.new('log/production.log')

编辑:我尝试使用 config.logger 在 Production.rb 中执行相同的操作,但它总是被覆盖。所以我决定采用这种方法。

You might need to set Rails.logger to ActiveSupport::Logger by creating an initializer.

Check the value by Rails.logger if it shows <RailsStdoutLogging::StdoutLogger: change it to active support.

config/initializer/logger.rb 

Rails.logger = ActiveSupport::Logger.new('log/production.log')

EDIT: I tried doing the same in production.rb using config.logger but it always gets overwritten. So i decided to go with this approach.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文