production.log 中没有日志消息 [英] No log messages in production.log

查看:51
本文介绍了production.log 中没有日志消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个演示 HelloWorld Rails 应用程序并使用 WEBrick 对其进行了测试(它甚至不使用数据库,它只是一个打印hello world"的控制器).然后我尝试将它部署到由 Passenger 驱动的本地 Apache.事实上,这个测试只是为了让乘客工作(这是我在 Apache 上的第一次部署).现在我什至不确定Passenger 是否有效,但我在Apache 方面没有收到任何错误.

I wrote a demo HelloWorld Rails app and tested it with WEBrick (it doesn't even use a DB, it's just a controller which prints "hello world"). Then I tried to deploy it to a local Apache powered with Passenger. In fact this test is just to get Passenger working (it's my first deploy on Apache). Now I'm not even sure that Passenger works, but I don't get any error on the Apache side.

当我启动 http://rails.test/ 时,浏览器会显示 Rails 500 错误页面 - 所以我假设 Passenger 工作正常.我想查一下日志,但结果production.log是空的!我不认为这是一个权限问题,因为如果我删除文件,它会在我重新加载页面时重新创建.我尝试更改 conf/environments/production.rb 中的日志级别,尝试使用 Rails 控制台生产和

When I fire http://rails.test/ the browser shows the Rails 500 error page - so I assume that Passenger works. I want to investigate the logs, but it happens that production.log is empty! I don't think it's a permission problem, because if I delete the file, it is recreated when I reload the page. I tried to change the log level in conf/environments/production.rb, tried to manually write to log file with Rails console production and

 Rails.logger.error('asdf')

它返回 true 但没有写入 production.log.路径(根据 Rails.logger.inspect 获得)是正确的,我注意到如果我手动删除该文件,则会重新创建该文件.我怎么知道发生了什么?

it returns true but nothing gets written to production.log. The path (obtained per Rails.logger.inspect) is correct, and I remark that the file is recreated if I manually remove it. How can I know what's going on?

(我已经检查了 Apache 日志,并且我为 Passenger 设置了最高调试级别,但它似乎是 Rails 问题,所以没有被服务器记录)

推荐答案

假设您运行的是 Rails 3.2.1,这是一个错误.它是 在 3.2.2 中修补.

Assuming you're running Rails 3.2.1, this is a bug. It was patched in 3.2.2.

如果您因任何原因无法升级到 3.2.2,请此评论在 GitHub 上有一个解决方法:

If you can't upgrade to 3.2.2 for any reason, this comment on GitHub has a workaround:

# config/initializers/patch_rails_production_logging.rb
Rails.logger.instance_variable_get(:@logger).instance_variable_get(:@log_dest).sync = true if Rails.logger

这篇关于production.log 中没有日志消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆