Open belgoros opened 6 years ago
Have you read this note: https://github.com/dwbutler/logstash-logger#logstash-never-receives-any-logs and tried setting sync: true
?
@dwbutler Thank you, I've tried to set sync: true
in my staging.rb
file:
config.log_formatter = ::Logger::Formatter.new
...
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|
exceptions = %w[controller action format id]
{
time: event.time,
stack: 'decastore',
host: event.payload[:host],
params: event.payload[:params].except(*exceptions)
}
end
config.lograge.logger = LogStashLogger.new(
type: :tcp,
host: ENV['logstash_host'],
port: ENV['logstash_port'],
verify_hostname: false,
sync: true
)
end
I also tries to just run the following in rails console
:
logger = LogStashLogger.new(type: :tcp, host: 'logstash-host.org', port: 3332, verify_hostname: false, sync: true)
logger.info 'decastore => test port 3332'
It fails both with udp
and tcp
type values.
Do I need to add special settings to put into the Logstash configuration file or any others to make it work ? Can firewall or proxy settings block that ? Actually, I can see logs written only
pic.log
file.I have the following gems declared in Rails API
Gemfile
:Here is the settings in
config/environement/pic.rb
:there are no logs when I tried to see it in Kibana dashboard (I hoped to filter by decastore by setting
name
option):Even when trying to run the following ruby script:
nothing is sent either.