-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add support for Socket Logging Handler #23128
Conversation
This comment has been minimized.
This comment has been minimized.
Hi, Thanks for this! I think the changes are more complicated than necessary. Personally I would prefer something like: https://github.com/quarkusio/quarkus/compare/main...geoand:%2323127?expand=1. Furthermore, we will need to have the commits squashed. |
Hi @geoand |
No rush |
* The log message formatter. json or pattern is supported | ||
*/ | ||
@ConfigItem(defaultValue = "pattern") | ||
String formatter; |
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.
Why is this added vs what SysLogConfig?
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 added as the output where you are sending messages can require formatted output differently than the Pattern. In our case we have logstash which has input tcp and json_lines. We need custom attributes/fields to add to the json formatted log meesage. If you have some other suggestion how to achieve it - I am happy to modify it.
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.
@gsmet WDYT about this? Does this use case warrant doing something different than what our SysLog handling does?
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.
Initially I thought I will use logging-json extension however this extension is limited to console logging. Maybe it would be more beneficial to extend that support instead and keep socket logging clean
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.
Yeah, I think that's a better approach
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.
HI @geoand, @gsmet ,
I have reworked the code completely. Now socket handler in core has just pattern and logging-json was extended to support all handlers not just console as it was before. Now file, console, syslog, socket and also named handlers can log as json. Previous implementation of consoleFormatter was opiniated and if JSON was added as extension basic console but also all named handlers were forced to log as JSON. I kept the original behavior but personally I am not fan of it. With "json=false" you can set console to use PatternFormatter and some named console handlers to use JSON. But you cannot use console as JSON and some named console handler to use Pattern. Its just because implementation should be backward compatible.
If users add logging-json extension
- all handlers will start log to JSON (even file,syslog,socket) . Not sure if its ok?
- Additional fields can be defined as quarkus.log.socket.json.additional-field.myownfield.value=testingvalue
- Keyoverrides was exposed too
I changed integration test of logging-json as previous one was not doing anything.
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.
Thanks a lot @JozefDropco.
I'll have a look soon
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.
I somehow missed this PR but I wonder if the work I did in #25505 isn't somehow related.
I probably need to have another look at it.
@JozefDropco we can't remove build items as this PR does as that could break other extensions |
Hi @geoand , |
I'll have to find some spare time to look into it and let you know. Thanks for your work on this and for your patience |
Lets say this PR didn't exist, what is your end goal here? Can you please state your end goal(s) clearly? Thanks |
HI @geoand, I am able to log to kibana with logback without any issues but this is true for the application. But not for the server. Quarkus is using JUL (jboss implementation with MDC support). but we wouldnt like to write our application dependeing on server directly. We would like to use SLF4J with logback. When I was trying I was unable to force quarkus to use our impelmentation instead jboss-logmanager in DEV mode. When I build it as uber-jar it was working correctly. Is there a specific reason why it wasnt working? |
So in order to make things absolutely clear, what you need is support for the Socket logging handler along with JSON support, correct? If so, then I think we'll need to figure out some changes to allow JSON support in other handlers as well |
Hi, honestly the ConsoleFormatter build item is quite hardcoded and I don't
see any reason why somebody would need to log as json in console unless
this output is not sent via filebeat somewhere else. Nevertheless I was
able to hack it. In application I use slf4j with logback (with tcp
appender). I use Command to start server from main method where I reset
handlers of JUL and bind it to slf4j. Now all logs are flowing through
logback to logstash. Anyways I am opened to implement even more
straightforward solution if you are opened to accept it
Kind regards, Jozef
|
I agree with you that currently the json support is very hard coded and we should probably make it possible to have json support across all handlers. The reason to log to json in the console is because in Kubernetes environments applications usually just log to the console and have the platform ship the logs wherever is necessary. |
* console logging formatting configuration and use the formatter provided instead. If multiple formatters | ||
* are enabled at run time, a warning message is printed and only one is used. | ||
*/ | ||
public final class LogConsoleFormatBuildItem extends MultiBuildItem { |
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.
👎🏻 Removing this build item will break other extensions
I'm going to close this. We made several changes in how we can support JSON in other logging transports (which also led to this PR conflicting a lot) so it's probably a good idea to revisit the issue with a fresh mind and make sure we agree on the approach and on what's needed. Thanks for the effort anyway. Feel free to ping me to have a discussion about how to pursue this. I will be happy to provide the infrastructure so that the implementation is easier on your side. |
Resolves #23127