-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Migrate Logstash to Log4j2 Logging #5651
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
Conversation
Hi, Just a remark : I think that ExampleEvent.java and Main.java should be in |
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@JsonSerialize(using = CustomLogEventSerializer.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that annotation @JsonSerialize(using = CustomLogEventSerializer.class)
is not useful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, the current state of the code is part exploratory. so there are lingering paths of code that may or may not be necessary in the next revision
99dcea0
to
d33244a
Compare
e090a31
to
c09b843
Compare
@talevy can you fix the tests? |
gem "webrick", ">= 0" | ||
gem "poseidon", ">= 0" | ||
gem "snappy", ">= 0" | ||
gem "webmock", "~> 1.21.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is probably left from installing something, let make sure we dont merge it in master.
@talevy I did a first pass looking great so far, before I test it manually I think the next would be:
Theses two things will greatly reduce the size of the PR. |
646680a
to
065461c
Compare
I have tested this PR with the
if you look at the beats code this is due of the usage of string interpolation. see https://github.com/logstash-plugins/logstash-input-beats/blob/master/src/main/java/org/logstash/beats/Server.java#L59 logger.info("Starting server on port: {}", this.port); We love structured log, since I control this library I can rewrite all the statements using the @talevy Can we find an elegant solution for that? |
#4820 introduced The refactor of the runner to use the new settings class changes that for Using this command with the current PR doesnt seems to do anything? Can we add back the support?
|
Other than the 2 previous comment, we are really close to get this merged |
@suyograo I am OK to have another PR to add the --log-in-json. |
return new StructuredMessage(message, params); | ||
} else { | ||
return new ParameterizedMessage(message, params); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that the returned Message
instance is not always a StructuredMessage
, it's maybe relevant to rename this class to something like LogstashMessageFactory
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. I'll update
@@ -0,0 +1,2 @@ | |||
Log4jLogEventFactory=org.logstash.log.LogstashLogEventFactory | |||
log4j2.messageFactory=org.logstash.log.LogstashMessageFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice ! 👍
@talevy Nice remove 👍 |
@talevy @fbaligand I've gone through the last iteration of this PR and it fixed all the issues we had with string interpolation. The only thing I've noticed is the unchecked warning, we might want to suppress that warning.
|
thanks. I added a |
LGTM |
finally! thanks @fbaligand, @ph, and @jordansissel for the reviews! I will follow-up with some items left over now. the meta issue should have captured all the points in checkpoints and/or PRs: #5650. |
Migrate to use Log4j2 for Logstash logging
Meta issue describing this issue: #5650
*_Quoted from the meta issue*_
Goal:
Proposed Implementation:
Migrate from Cabin to Log4j2 as the logging library for Logstash Core and its plugins.
Reason for library change:
Logstash and its plugin's usage of Java libraries that use Log4j/SLF4j is growing. This is leading to un-captured logging by core as it is running the pipeline. Cabin is the current logging library used by Logstash, but it's support for these java libraries is limited. Configuration of these java loggers is also not managed by Logstash natively, this yields confusing warning messages when using specific plugins, like Kafka. Even Logstash's core (Logstash Event in Java) is straying away from Cabin-friendly logging land.