diff --git a/Gemfile b/Gemfile index 05d0d66b4df..ce14fdefda6 100644 --- a/Gemfile +++ b/Gemfile @@ -173,6 +173,7 @@ gem 'memory_profiler', require: false, platform: :mri gem 'cppjieba_rb', require: false gem 'lograge', require: false +gem 'logstash-event', require: false gem 'logster' gem 'sassc', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 59bc9e2574c..6bf55bdacd6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -155,6 +155,7 @@ GEM activesupport (>= 4, < 5.2) railties (>= 4, < 5.2) request_store (~> 1.0) + logstash-event (1.2.02) logster (1.2.8) loofah (2.1.1) crass (~> 1.0.2) @@ -438,6 +439,7 @@ DEPENDENCIES http_accept_language (~> 2.0.5) listen lograge + logstash-event logster lru_redux mail diff --git a/config/initializers/100-lograge.rb b/config/initializers/100-lograge.rb index 565a29277bc..304fde3ced4 100644 --- a/config/initializers/100-lograge.rb +++ b/config/initializers/100-lograge.rb @@ -7,11 +7,18 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV[" config.lograge.custom_options = lambda do |event| exceptions = %w(controller action format id) + params = event.payload[:params].except(*exceptions) + params[:files].map!(&:headers) if params[:files] + output = { - params: event.payload[:params].except(*exceptions), + params: params, database: RailsMultisite::ConnectionManagement.current_db, time: event.time, } end + + if ENV["LOGSTASH_FORMATTER"] + config.lograge.formatter = Lograge::Formatters::Logstash.new + end end end