StartupInfoLogger logs the result of calling InetAddress.getLocalHost().getHostName(). This call can take a long time as we've discussed in the past. That discussion concluded with us logging a warning when resolving the host name takes too long.
With a new major release we have another option available to us: remove the hostname from the log message. I am in favour of doing so as I don't think it adds much value at the moment. If you're viewing the logs locally, knowing the hostname isn't useful. If you're viewing them remotely you presumably now where the logs came from. If you're viewing aggregated logs, having an identifier per log entry would be far more useful than mentioning the hostname in one entry which may have been lost long ago via a rollover.
Comment From: sdeleuze
I would love to see this change in Spring Boot 3, I mean really! On Mac or some Cloud platforms resolving localhost DNS at startup can take a huge amount of time (including for native), so it seems to be much safer to avoid this friction point on both DevXP and Cloud deployments by default, and let people add the hostname or any other differentiator via the log aggregation system or via Logback configuration.
That would be a much safer default, would make Spring Boot startup time more robust and predictive, while still allowing much more useful per lines differentiator use case via explicit configuration.
Comment From: mhalbritter
I totally agree with your line of reasoning, Andy.
Comment From: philwebb
Fine by me.
Comment From: philwebb
Another option might be to look for COMPUTERNAME, HOSTNAME or HOST environment variables. That should be quick. According to stackoverflow the HOSTNAME is the pod in Kubernetes which might be useful.
Comment From: sdeleuze
A significant limitation is that on most Unix systems, HOSTNAME is not exported, hence not visible from Java by default, see https://stackoverflow.com/a/17956000.
So I guess the 2 options would be either:
- Remove the hostname from the log message as suggested by @wilkinsona in the description to have a consistent behavior on all platforms.
- Use COMPUTERNAME on Windows or HOSTNAME when exported so visible from Java in Unix-like platforms (not sure about HOST) when available.
Comment From: wilkinsona
We've decided to remove the hostname from the log message.