ruby-on-railsruby-on-rails-3herokuunicornpapertrail-app

Hide rendering of partials from rails logs


I believe the default behavior of rails logging on production is to not output the rendering of all partials. This should log in development but not on production.

However, I'm seeing this in production and I'm not sure how to remove it. My logs are too noisy. My production environment is Heroku running Unicorn and using Papertrail to view my logs. I know Unicorn does some wonky stuff with logs and to get them working properly in the first place I had to add this to my production.rb:

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

( Explained here: http://help.papertrailapp.com/kb/configuration/unicorn )

But even with log_level INFO I'm seeing huge blocks of these in all my logs:

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) 

Solution

  • I got the following answer from a papertrail:

    I think the quickest way to deal with this is to use our log filtering functionality. That'll let you drop anything that matches a regex and will save you from having to make any app configuration changes.

    In the longer term, you'll probably want to silence these messages at source. Lograge is probably your best bet for that. You may find it also removes a few other bits but give it a go and let me know what you think.

    I know this is probably irrelevant to you at the moment, but for future use you might also find some other useful tips here. It covers lograge, removing static asset requests and unnecessary actions,

    Let me know if you need help with anything mentioned above.