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

make SocketAppender support server list #3442

Open
lu-xiaoshuang opened this issue Feb 8, 2025 · 8 comments
Open

make SocketAppender support server list #3442

lu-xiaoshuang opened this issue Feb 8, 2025 · 8 comments

Comments

@lu-xiaoshuang
Copy link

lu-xiaoshuang commented Feb 8, 2025

Typically, applications generate massive amounts of log data, and these data should be sent to backend systems for storage, analysis and so on.

At present, a SocketAppender only supports one address-port. Seems that remote server represented by this address-port is very likely the bottleneck (network traffic) and single point failure endpoint (without gateway).

Would it be possible that SocketAppender supports server list?

@swebb2066
Copy link

Have you considered sending logging events via the fluent-bit Forward Upstream plugin?

@lu-xiaoshuang
Copy link
Author

Have you considered sending logging events via the fluent-bit Forward Upstream plugin?

Good idea. Thank you for your thoughts. @swebb2066

It would be great if there are no additional prerequisites.

@ppkarwasz
Copy link
Contributor

@lu-xiaoshuang,

At present, a SocketAppender only supports one address-port. Seems that remote server represented by this address-port is very likely the bottleneck (network traffic) and single point failure endpoint (without gateway).

It would be great if there are no additional prerequisites.

The Socket appender is based on the basic Java socket classes. These classes don't provide support for connection pooling, so we would need additional libraries (like Apache MINA or Netty) or a lot of custom code to handle multiple connections.

Since TCP does not guarantee a reliable delivery without message loss, it is probably better to look at message queue appenders. Some of them do support multiple servers.

@vy
Copy link
Member

vy commented Feb 10, 2025

@lu-xiaoshuang, curious: what is the log sink you use where you encounter this problem?

@lu-xiaoshuang
Copy link
Author

@lu-xiaoshuang, curious: what is the log sink you use where you encounter this problem?

logstash

@lu-xiaoshuang
Copy link
Author

lu-xiaoshuang commented Feb 12, 2025

@lu-xiaoshuang,

At present, a SocketAppender only supports one address-port. Seems that remote server represented by this address-port is very likely the bottleneck (network traffic) and single point failure endpoint (without gateway).

It would be great if there are no additional prerequisites.

The Socket appender is based on the basic Java socket classes. These classes don't provide support for connection pooling, so we would need additional libraries (like Apache MINA or Netty) or a lot of custom code to handle multiple connections.

Since TCP does not guarantee a reliable delivery without message loss, it is probably better to look at message queue appenders. Some of them do support multiple servers.

Thanks, @ppkarwasz

KafkaAppender is not capable of sending logs generated by org.apache.kafka:kafka-clients:jar, is it?

By the way, If community decides to make SocketAppender support server list, what about creating multiple sockets? When append method is invoked, log4j2 can choose a socket randomly. I think this simple solution is free of connection pool stuff.

@ppkarwasz
Copy link
Contributor

KafkaAppender is not capable of sending logs generated by org.apache.kafka:kafka-clients:jar, is it?

Right, that usually causes problems with recursive logging.

By the way, If community decides to make SocketAppender support server list, what about creating multiple sockets? When append method is invoked, log4j2 can choose a socket randomly. I think this simple solution is free of connection pool stuff.

Log4j is highly pluggable, so I would recommend to:

  1. Create and publish a new appender (let's say MultiSocketAppender) in your personal or company repo under Apache-2.0.
  2. Test the plugin in your test environment.
  3. Announce it on our [email protected] mailing list. We will add a section for it in our Appenders page, so users can easily find it.
  4. If the appender is well received by users we will consider adding it to the standard distribution.

Note that we are adopting the same strategy for our own plugins, e.g. my copernik-eu/log4j-tomcat is waiting for some user feedback.

@lu-xiaoshuang
Copy link
Author

  1. in your personal or company repo under Apache-2.0.

Good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants