Mike Rogers ✈️
Posted on October 7, 2020
I've love steaming through the Rails logs, they can help debug problems pretty quickly. However by default they're pretty verbose, which can make searching through & storing a bit tricky.
In this video, I go through the Lorgage gem for Ruby On Rails & show how it can be used to reduce your logs to one line per a request.
The code
To remove attributes from our log lines, we passed a lambda to config.lograge.custom_options
.
# config/initializers/lograge.rb
Rails.application.configure do
config.lograge.enabled = true
config.lograge.custom_options = lambda do |event|
exceptions = %w[controller action]
{
params: event.payload[:params].except(*exceptions)
}
end
end
To filter parameters (replace them with "[FILTERED]") from our logs we added them to the filter_parameters
config option:
# config/initializers/filter_parameter_logging.rb
Rails.application.config.filter_parameters += [:password, :secret_pass]
💖 💪 🙅 🚩
Mike Rogers ✈️
Posted on October 7, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.