dwbutler / logstash-logger

Ruby logger that writes logstash events
MIT License
456 stars 119 forks source link

`log_tags` breaking LogStash parser? #137

Closed cabello closed 7 years ago

cabello commented 7 years ago

Hi,

I have a Rails 5 app configured like the following config/environments/production.rb:

Rails.application.configure do
  config.lograge.formatter = Lograge::Formatters::Logstash.new
  config.log_tags = [:request_id]
end

This is a sample message that I am seeing in logz.io a ELK as a service provider:

[c069aa8b-b42b-4683-bfc2-c89f716c5c18] {"method":"GET","path":"/","format":"html","controller":"HealthcheckController","action":"index","status":200,"duration":2.17,"view":0.2,"db":0.67,"@timestamp":"2017-11-17T20:45:57.415Z","@version":"1","message":"[200] GET / (HealthcheckController#index)"}

I just did a test and removed the log_tags settings and everything was parsed into searchable fields.

Is that the expected behaviour? How do I log the request id otherwise? Using config.customize_event maybe?

dwbutler commented 7 years ago

This appears to be an issue with Lograge rather than LogStashLogger. You are using a log formatter provided by Lograge, which doesn't support tagged logging. If you use one of the built in formatters provided by LogStashLogger, tags should appear in the tags key of the event.