discourse/config/initializers/100-lograge.rb
2017-10-27 23:52:36 +08:00

29 lines
757 B
Ruby

if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["ENABLE_LOGRAGE"]
require 'lograge'
Rails.application.configure do
config.lograge.enabled = true
logstash_uri = ENV["LOGSTASH_URI"]
config.lograge.custom_options = lambda do |event|
exceptions = %w(controller action format id)
output = {
params: event.payload[:params].except(*exceptions),
database: RailsMultisite::ConnectionManagement.current_db
}
output[:type] = :rails if logstash_uri
output
end
if logstash_uri
require 'logstash-logger'
config.lograge.formatter = Lograge::Formatters::Logstash.new
config.lograge.logger = LogStashLogger.new(uri: logstash_uri)
end
end
end