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

Add support for Socket Logging Handler #23128

Closed
wants to merge 7 commits into from

Conversation

JozefDropco
Copy link

@JozefDropco JozefDropco commented Jan 24, 2022

Resolves #23127

@quarkus-bot

This comment has been minimized.

@quarkus-bot quarkus-bot bot added the area/dependencies Pull requests that update a dependency file label Jan 24, 2022
@JozefDropco JozefDropco changed the title https://github.com/quarkusio/quarkus/issues/23127 Extension: Loggging into UDP/TCP Socket Jan 24, 2022
@geoand geoand changed the title Extension: Loggging into UDP/TCP Socket Add support for Socket Logging Handler Jan 24, 2022
@geoand
Copy link
Contributor

geoand commented Jan 24, 2022

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.
Mind updating the PR along those lines?

Furthermore, we will need to have the commits squashed.

@JozefDropco
Copy link
Author

Hi @geoand
thanks I will update it. give me some time and I will update it

@geoand
Copy link
Contributor

geoand commented Jan 24, 2022

No rush

* The log message formatter. json or pattern is supported
*/
@ConfigItem(defaultValue = "pattern")
String formatter;
Copy link
Contributor

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?

Copy link
Author

@JozefDropco JozefDropco Jan 24, 2022

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.

Copy link
Contributor

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?

Copy link
Author

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

Copy link
Contributor

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

Copy link
Author

@JozefDropco JozefDropco Jan 26, 2022

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.

Copy link
Contributor

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

Copy link
Member

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.

@geoand
Copy link
Contributor

geoand commented Jan 28, 2022

@JozefDropco we can't remove build items as this PR does as that could break other extensions

@JozefDropco
Copy link
Author

Hi @geoand ,
ok what do you suggest than? keep original extension as it was and introduce new build item + new extension which will be using the new code?

@geoand
Copy link
Contributor

geoand commented Jan 30, 2022

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

@geoand
Copy link
Contributor

geoand commented Jan 31, 2022

Lets say this PR didn't exist, what is your end goal here?
I am trying to understand what the reason is for all the changes, as they are certainly not all necessary for implementing #23127 (as my https://github.com/quarkusio/quarkus/compare/main...geoand:%2323127?expand=1).

Can you please state your end goal(s) clearly?

Thanks

@JozefDropco
Copy link
Author

HI @geoand,
our goal is to be able to log into logstash under TCP with SSL enabled. We need to structure the messages as JSON with some custom fields. Index in logstash is not managed by us.

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?

@geoand
Copy link
Contributor

geoand commented Feb 2, 2022

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

@JozefDropco
Copy link
Author

JozefDropco commented Feb 6, 2022 via email

@geoand
Copy link
Contributor

geoand commented Feb 11, 2022

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 {
Copy link
Contributor

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

@gsmet
Copy link
Member

gsmet commented Feb 2, 2023

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.

@gsmet gsmet closed this Feb 2, 2023
@quarkus-bot quarkus-bot bot added the triage/invalid This doesn't seem right label Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core area/dependencies Pull requests that update a dependency file area/logging triage/invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logging into socket
4 participants