Add type when shipping logs to logstash.

This commit is contained in:
Guo Xiang Tan 2017-10-27 23:31:17 +08:00
parent d487be759c
commit afdd31473d

View File

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