ruby-on-rails – 隐藏从rails日志的部分渲染

我相信rails在生产中的默认行为是不输出所有部分的渲染.这应该登录开发,但不能生产.

但是,我在生产中看到这个,我不知道如何删除它.我的日志太吵了我的生产环境是Heroku运行Unicorn并使用Papertrail查看我的日志.我知道Unicorn使用日志做了一些蛮横的东西,并让他们正常工作,首先我不得不将它添加到我的production.rb中:

config.logger = Logger.new(STDOUT)
  config.logger.level = Logger.const_get('INFO')

(在这里解释:http://help.papertrailapp.com/kb/configuration/unicorn)

但即使使用log_level INFO,我在所有日志中看到巨大的块:

Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_caption.html.erb (0.7ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_rights.html.erb (2.1ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_category.html.erb (4.8ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_caption.html.erb (0.3ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_rights.html.erb (0.4ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_category.html.erb (4.4ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_caption.html.erb (0.3ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_rights.html.erb (0.3ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_category.html.erb (1.8ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_caption.html.erb (0.4ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_rights.html.erb (4.6ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_category.html.erb (2.1ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_caption.html.erb (0.3ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_rights.html.erb (0.4ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_category.html.erb (4.1ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_caption.html.erb (0.2ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_rights.html.erb (1.8ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_category.html.erb (6.0ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_caption.html.erb (0.5ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_rights.html.erb (0.8ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_category.html.erb (1.9ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_caption.html.erb (0.3ms) 
Jun 25 22:15:15 tacktile app/web.1:    Rendered photos/pieces/_rights.html.erb (0.7ms)

解决方法

对于Rails 4(至少):

请尝试在您的config / environments / development.rb中

config.action_view.logger = nil

相关文章

以下代码导致我的问题: class Foo def initialize(n=0) @n = n end attr_accessor :n d...
这是我的spec文件,当为上下文添加测试“而不是可单独更新用户余额”时,我得到以下错误. require 's...
我有一个拦截器:DevelopmentMailInterceptor和一个启动拦截器的inititializer setup_mail.rb. 但我想将...
例如,如果我有YAML文件 en: questions: new: 'New Question' other: recent: ...
我听说在RSpec中避免它,let,let !,指定,之前和主题是最佳做法. 关于让,让!之前,如果不使用这些,我该如...
我在Rails中使用MongoDB和mongo_mapper gem,项目足够大.有什么办法可以将数据从Mongoid迁移到 Postgres...