Hide rendering of partials from rails logs
Instead of completely disabling actionview logging (as described in another answer), I opted to change the logging level for rendering to DEBUG
. This way, it can be easily omitted from production logs by setting the log level to INFO
or higher.
Note, this is for rails 5.2. I'm unsure if it would work on other versions.
module ViewLoggingOverride
def info(progname = nil, &block)
logger.debug(progname, &block) if logger
end
end
ActionView::LogSubscriber.include(ViewLoggingOverride)
Relevant rails code:
https://github.com/rails/rails/blob/5-2-stable/actionview/lib/action_view/log_subscriber.rb
https://github.com/rails/rails/blob/5-2-stable/activesupport/lib/active_support/log_subscriber.rb#L93-L99
Use Lograge, it removes rendering times for partials
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.
For Rails 4 (at least):
Try this in your config/environments/development.rb
config.action_view.logger = nil