How to add the request parameters along with in lograge outputted files
Here is how to include the request parameters n lograge formatted log files.
Lograge is a RubyGem that modifies the rails log format for you so it’s easier to parse by parsers like Logstash, for example.
Here is what needs to be added to each file:
Gemfile:
gem "lograge"
config/environments/production.rb
MyApp::Application.configure do config.lograge.enabled = true # custom_options can be a lambda or hash # if it's a lambda then it must return a hash config.lograge.custom_options = lambda do |event| unwanted_keys = %w[format action controller] params = event.payload[:params].reject { |key,_| unwanted_keys.include? key } # capture some specific timing values you are interested in {:params => params } end
app/controllers/application_controller.rb
def append_info_to_payload(payload) super payload["params"] = request.params endHow to add the request parameters along with in lograge outputted files,
One Comment to “How to add the request parameters along with in lograge outputted files”