我无法弄清楚为什么lograge
文件中没有使用logstash
和production.rb
defined s从Rails API应用发送到Kibana的日志:
#config/environments/production.rb
if ENV['RAILS_LOG_TO_STDOUT'].present?
config.log_level = :info
config.lograge.enabled = true
config.lograge.base_controller_class = 'ActionController::API'
config.lograge.formatter = Lograge::Formatters::Logstash.new
config.lograge.custom_options = lambda do |event|
{ :params => event.payload[:params] }
end
config.lograge.logger = LogStashLogger.new(
type: :tcp,
host: ENV['logstash_host'],
port: ENV['logstash_port'],
verify_hostname: false,
sync: true
)
config.lograge.custom_options = lambda do |event|
exceptions = %w[controller action format id]
{
time: event.time,
stack: 'decastore',
host: event.payload[:host],
params: event.payload[:params].except(*exceptions)
}
end
end
在生产环境中启动服务器时,我将RAILS_LOG_TO_STDOUT
设置为true
,但是在Kibana中仍然没有日志吗?有任何想法吗 ?谢谢。