EXPERIMENTAL: Allow app to Logstash directly.
This commit is contained in:
parent
0a7035e5d3
commit
d487be759c
3
Gemfile
3
Gemfile
|
@ -172,7 +172,8 @@ gem 'memory_profiler', require: false, platform: :mri
|
|||
|
||||
gem 'cppjieba_rb', require: false
|
||||
|
||||
gem 'lograge'
|
||||
gem 'lograge', require: false
|
||||
gem 'logstash-logger', require: false
|
||||
gem 'logster'
|
||||
|
||||
gem 'sassc', require: false
|
||||
|
|
|
@ -155,6 +155,9 @@ GEM
|
|||
activesupport (>= 4, < 5.2)
|
||||
railties (>= 4, < 5.2)
|
||||
request_store (~> 1.0)
|
||||
logstash-event (1.2.02)
|
||||
logstash-logger (0.25.1)
|
||||
logstash-event (~> 1.2)
|
||||
logster (1.2.8)
|
||||
loofah (2.1.1)
|
||||
crass (~> 1.0.2)
|
||||
|
@ -438,6 +441,7 @@ DEPENDENCIES
|
|||
http_accept_language (~> 2.0.5)
|
||||
listen
|
||||
lograge
|
||||
logstash-logger
|
||||
logster
|
||||
lru_redux
|
||||
mail
|
||||
|
|
|
@ -1,10 +1,27 @@
|
|||
if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV["ENABLE_LOGRAGE"]
|
||||
require 'lograge'
|
||||
|
||||
Rails.application.configure do
|
||||
config.lograge.enabled = true
|
||||
|
||||
config.lograge.custom_options = lambda do |event|
|
||||
exceptions = %w(controller action format id)
|
||||
{ params: event.payload[:params].except(*exceptions) }
|
||||
|
||||
{
|
||||
params: event.payload[:params].except(*exceptions),
|
||||
type: :rails
|
||||
}
|
||||
end
|
||||
|
||||
if (logstash_uri = ENV["LOGSTASH_URI"].present?)
|
||||
require 'logstash-logger'
|
||||
|
||||
config.lograge.formatter = Lograge::Formatters::Logstash.new
|
||||
|
||||
config.lograge.logger = LogStashLogger.new(
|
||||
type: :tcp,
|
||||
uri: logstash_uri
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue