Skip to content

Conversation

@magnusbaeck
Copy link
Contributor

This mirrors what the json codec already does. Fixes #21.

LogStash::Event.from_json(json).each { |event| yield event }
rescue LogStash::Json::ParserError
rescue LogStash::Json::ParserError => e
@logger.error("JSON parse error, original data now in message field", :error => e, :data => json)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this condition is automatically recovered by Logstash, I don't think logging it as an error is the right choice. Maybe info? or warn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. I'll stick to a warning since that matches the default log level. Hiding what should be obvious signs of trouble behind a --verbose invocation seems ill-advised.

This mirrors what the json codec already does.
@magnusbaeck magnusbaeck changed the title Log an error when the JSON parsing fails Log a warning when the JSON parsing fails Jun 30, 2016
@magnusbaeck
Copy link
Contributor Author

Updated according to your suggestion @jordansissel. Please have another look.

@jordansissel
Copy link
Contributor

LGTM

@elasticsearch-bot
Copy link

Jordan Sissel merged this into the following branches!

Branch Commits
master e789f4f
@magnusbaeck magnusbaeck deleted the log-parse-errors branch March 24, 2019 19:35
jsvd pushed a commit to jsvd/logstash-codec-json_lines that referenced this pull request Nov 20, 2019
This mirrors what the json codec already does. Fixes logstash-plugins#25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants