Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Logstash to write its logs in JSON format #5277

Closed
wants to merge 2 commits into from

Conversation

jordansissel
Copy link
Contributor

Allow Logstash to write its logs in JSON format

This is made available by a --log-in-json flag. Default is false.
When false, the old behavior [1] is used.

When true, JSON logs are emitted.

[1] The old behavior is really two things. First, using Object#inspect to
serialize. Second, to color the output if the IO is a tty.

For #1569

This is a manual backport of PR #4820 into the 2.x branch.

This is made available by a --log-in-json flag. Default is false.
When false, the old behavior [1] is used.

When true, JSON logs are emitted.

[1] The old behavior is realy two things. First, using Object#inspect to
serialize. Second, to color the output if the IO is a tty.

For #1569

This is a manual backport of PR #4820 into the 2.x branch.
@ph ph added the v2.4.0 label May 10, 2016
@ph ph self-assigned this May 10, 2016
@ph
Copy link
Contributor

ph commented May 10, 2016

With a clean checkout of the repository.

After doing:

rake bootstrap
rake test:install-core
rake test:core #sucessfully run

When I start logstash with this line it crash. :(

/t/logstash git:pr/5277 ❯❯❯ bin/logstash -e 'input { generator {}}' --log-in-json                                                                         ✱
LogStash::Json::GeneratorError: Cannot serialize instance of: LogStash::PluginLoadingError
      jruby_dump at /tmp/logstash/logstash-core/lib/logstash/json.rb:53
              << at /tmp/logstash/logstash-core/lib/logstash/logging/json.rb:15


@jordansissel
Copy link
Contributor Author

Hmm, kind of annoying that the tests don't catch something this simple. I'll see what I can do.

@jordansissel
Copy link
Contributor Author

@ph fixed.

@@ -480,7 +480,7 @@ def start_pipeline(id)
begin
pipeline.run
rescue => e
@logger.error("Pipeline aborted due to error", :exception => e, :backtrace => e.backtrace)
@logger.error("Pipeline aborted due to error", :exception => e.class.name, :backtrace => e.backtrace)
Copy link
Contributor

@ph ph May 10, 2016

Choose a reason for hiding this comment

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

This is somewhat common to use this kind of line in the plugins, I've seen it a lot and I have use it myself.

@ph
Copy link
Contributor

ph commented May 10, 2016

It fixed the issue for me, @jordansissel 2.4/5.0 beta absolutely need to go out with the new version of jrjackson, guyboertje/jrjackson#54

@ph
Copy link
Contributor

ph commented May 10, 2016

The code LGTM.

@jordansissel
Copy link
Contributor Author

@ph +1 on shipping 2.4/5.0beta1 with a newer jrjackson

@ph
Copy link
Contributor

ph commented May 10, 2016

@jordansissel I have created this #5278 to make sure we dont drop the ball. I am +1 to merge your changes.

elasticsearch-bot pushed a commit that referenced this pull request May 10, 2016
This is made available by a --log-in-json flag. Default is false.
When false, the old behavior [1] is used.

When true, JSON logs are emitted.

[1] The old behavior is realy two things. First, using Object#inspect to
serialize. Second, to color the output if the IO is a tty.

For #1569

This is a manual backport of PR #4820 into the 2.x branch.

Fixes #5277
@elasticsearch-bot
Copy link

Jordan Sissel merged this into the following branches!

Branch Commits
2.x 39e0ef5, 4e1f825

@suyograo suyograo closed this May 11, 2016
@suyograo suyograo deleted the backport/json-logging-pr-4820 branch May 11, 2016 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants