2017-09-10 17:25:29 +05:30
|
|
|
# Only use Lograge for Rails
|
2020-03-09 13:42:32 +05:30
|
|
|
unless Gitlab::Runtime.sidekiq?
|
2017-09-10 17:25:29 +05:30
|
|
|
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)
|
2019-12-26 22:10:19 +05:30
|
|
|
config.lograge.before_format = lambda do |data, payload|
|
|
|
|
data.delete(:error)
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
# This isn't a user-reachable controller; we use it to check for a
|
|
|
|
# valid CSRF token in the API
|
|
|
|
config.lograge.ignore_actions = ['Gitlab::RequestForgeryProtection::Controller#index']
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
# Add request parameters to log output
|
2020-04-08 14:13:33 +05:30
|
|
|
config.lograge.custom_options = Gitlab::Lograge::CustomOptions
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|