t0xa / gelfj

Graylog Extended Log Format (GELF) implementation in Java and log4j appender without any dependencies.
https://github.com/t0xa/gelfj/wiki
Other
187 stars 115 forks source link

Removed caching of the DNS resolution - the code will now rely on the… #124

Closed gaspardpetit closed 3 years ago

gaspardpetit commented 6 years ago

… JVM's cache instead and rely on the networkaddress.cache.ttl security property;

For the UDP sender, also added a refresh of the channel every 5 minutes - otherwise the same channel would keep sending to the same IP forever.

Signed-off-by: Gaspard Petit gaspard.petit@eidosmontreal.com

gaspardpetit commented 6 years ago

This would resolve the following issue: https://github.com/t0xa/gelfj/issues/70

gaspardpetit commented 6 years ago

With this solution, every new reconnect of the GelfTCPSender.java will lookup the hostname instead of reuse the cached resolution. Bear in mind that this ends up using the JVM's DNS cache, so it's not an actually lookup every time.

For the GelfUDPSender.java I had to do it in two places: (1) lookup hostname instead of cached resolution and (2) force refresh of the UDP channel since otherwise it would remain open and clueless about the change forever. I used 5 mins, hardcoded - this is a reasonable value for us, but if somebody else wants to improve with configurable settings, that would be an improvement. Keep in mind that refreshing a datagram channel is quite fast since there is no remote connection involved.