logstash-plugins / logstash-input-kinesis

Logstash Plugin for AWS Kinesis Input
Apache License 2.0
45 stars 57 forks source link

Cannot launch Logstash. Failed to coerce java.util.logging.Level to org.apache.log4j.Level #16

Closed dichenli closed 7 years ago

dichenli commented 7 years ago

I'm having problem launching Logstash 5.1.1 with this plugin.

Error log in /var/log/logstash/logstash-plain.log:

[2016-12-09T03:54:10,776][ERROR][logstash.agent           ] Pipeline aborted due to error {:exception=>#<TypeError: failed to coerce java.util.logging.Level to org.apache.log4j.Level>, :backtrace=>[
"/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-kinesis-2.0.2-java/lib/logstash/inputs/kinesis.rb:64
:in `register'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:353
:in `start_inputs'", "org/jruby/RubyArray.java:1613
:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:352
:in `start_inputs'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:228
:in `start_workers'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:183
:in `run'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:292
:in `start_pipeline'"]}

In kinesis.rb lines 60-66, it decides which log class to use based on logstash-core-plugin version. See: https://github.com/logstash-plugins/logstash-input-kinesis/blob/master/lib/logstash/inputs/kinesis.rb

I find my logstash-core-plugin version is exactly 2.1.12. So I manually changed the line 60 from if Gem::Version.new(LOGSTASH_CORE_PLUGIN_API) > Gem::Version.new('2.1.12') to if Gem::Version.new(LOGSTASH_CORE_PLUGIN_API) >= Gem::Version.new('2.1.12')

And the problem was solved for this EC2 instance.

Since I use AWS CloudFormation to deploy Logstash, it's very hard to manually update this file every time I deploy the stack. Could you help me find and fix the problem? Thank you!

dichenli commented 7 years ago

Update: I just downgraded Logstash to 5.0.2 and the problem is gone. Is it a bug introduced by 5.1.1?

codekitchen commented 7 years ago

Hm at first glance I thought this had to be related to the brokenness the core team found yesterday in https://github.com/elastic/logstash/issues/6374

But actually based on your workaround it looks like a logic error in this PR https://github.com/logstash-plugins/logstash-input-kinesis/pull/15

@hippolin how did you determine which version number of LOGSTASH_CORE_PLUGIN_API to use as the cutover? Does changing to >= look correct to you there?

dichenli commented 7 years ago

Thanks. I just launched a new instance with Logstash-5.0.2 installed. It uses logstash-core-plugin-api 2.1.16 now. So it seems somehow the newer versioned logstash (5.1.1) is using an older version of logstash-core-plugin-api (2.1.12).

jjensn commented 7 years ago

I have this issue as well

codekitchen commented 7 years ago

Thanks @hippolin for the fix, I've just pushed version 2.0.3 of this gem

dichenli commented 7 years ago

Thanks for the fix!