Moocar / logback-gelf

Logback plugin to send GELF messages to graylog2 server
Apache License 2.0
147 stars 59 forks source link

Use FQDN if possible. #32

Closed burberius closed 10 years ago

burberius commented 10 years ago

I have the problem that some systems are logged with their hostname only and others with the FQDN in our Graylog2. We have a test and a live net, which can be distinguished by their subdomain and I need that to separate the logging. I did some tests with the getCanonicalHostName method on different systems and it always gave the FQDN, so that is the right solution for us. It would be nice if that could be integrated in the next release.

Moocar commented 10 years ago

Hi, this would be a breaking change to existing users. E.g on my mac:

InetAddress.getLocalHost.getHostName() => "guerrero.homeoffice.wal-mart.com"
InetAddress.getLocalHost.getCanonicalHostName() => "192.168.1.126"

I would recommend adding a property that can be configured in logback.xml. E.g hostNameMechanism = getCanonicalHostName.

burberius commented 10 years ago

I changed it now, to use the CanonicalHostName only when it's a FQDN else use HostName, so it's the old behaviour. I don't want to added another property for such a little cosmetic change. ;-) There is also a Test for that now.

Moocar commented 10 years ago

Thanks for this, I updated the docstring for getLocalHostName and added a private isFQDN function to make it a bit more readable. Merged!