diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-19 08:44:04 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-19 08:44:04 +0000 |
commit | 9492fbc4473a88393ad857dcb49420507216c810 (patch) | |
tree | f09fed552b578f5c068dffdf7bf1416808553116 /config | |
parent | f45b96a01928c325a935c095468b321bec7cc15f (diff) | |
parent | e2b1c16ade09c0afde11d8b39bac9f1974c9b057 (diff) | |
download | gitlab-ce-9492fbc4473a88393ad857dcb49420507216c810.tar.gz |
Merge branch 'sh-structured-logging' into 'master'
Add structured logging for Rails processes
See merge request !12928
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/lograge.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb new file mode 100644 index 00000000000..14902316240 --- /dev/null +++ b/config/initializers/lograge.rb @@ -0,0 +1,21 @@ +# Only use Lograge for Rails +unless Sidekiq.server? + filename = File.join(Rails.root, 'log', "#{Rails.env}_json.log") + + Rails.application.configure do + config.lograge.enabled = true + # Store the lograge JSON files in a separate file + config.lograge.keep_original_rails_log = true + # Don't use the Logstash formatter since this requires logstash-event, an + # unmaintained gem that monkey patches `Time` + config.lograge.formatter = Lograge::Formatters::Json.new + config.lograge.logger = ActiveSupport::Logger.new(filename) + # Add request parameters to log output + config.lograge.custom_options = lambda do |event| + { + time: event.time, + params: event.payload[:params].except(%w(controller action format)) + } + end + end +end |