Closed pareeohnos closed 9 years ago
Lemme go through this long time due
I am having the same problem. Is there going to be any change in near future?
Should this be closed now?
I think so. Thanks @ilonashub for the fix
@pareeohnos thank you for the fixed code!
I'm writing an application that outputs a lot of debugging logs and informational logs, and have noticed an issue when using the
LogStasher.log
function. Whilst it is generating a JSON log output, and it is being written to the log stash log file, I've noticed that instead of it being completely JSON, it contains some plain text before, causing log stash to interpret the messages incorrectly.For example, if I call
LogStasher.log('info', 'Hello World')
, I then see that in mylogstash_development.log
file the following line has been addedThe JSON is perfect, but the beginning of the output is not quite right. When I launch logstash and kibana, I can then see that this output has been interpreted as the following JSON
Logstash has done a relatively good job here in that it hasn't simply rejected it, but as you can, the JSON output from LogStasher has been interpreted as plain text and put into the message field, rather than being an object in the message field.
I've dug through the code, and the only difference I can find is that for rails requests, the message is logged via
While the
log
method is logging viaI've done a quick monkey patch and changed the
log
method to work in the same way and the output is now correct. CallingLogStasher.log('info', 'Hello World')
now results in logstash parsing the following JSONAs you can see, the message is no longer in an unparsed plain text state, but is part of the actual JSON which is what I'd expect.
The
log
method I've got in my monkey patch is now