https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java#L558
I think it's used for a configuration property value that can be used for configuring the output file name and things like that. NetUtils could be refactored to have a swappable implementation of getLocalHostname() that could be mocked in unit tests, but if you add your hostname to your /etc/hosts file, the lookup is super fast and unnoticeable anyways. In a normal environment, this lookup is only done once and is subsequently cached internally by InetAddress, so it's not a problem in production environments in practice. On 8 January 2017 at 14:24, Mikael Ståldal <mikael.stal...@magine.com> wrote: > Why do we need to call get local host in setConfiguration? > > On Jan 8, 2017 12:32 AM, "Matt Sicker" <boa...@gmail.com> wrote: > >> Turns out that if you're missing /etc/hosts entries for your machine's >> host name, then InetAddress.getLocalHost() needs to do a lot of DNS lookups >> to determine what IP addresses are associated to your hostname. If you're >> on IPv6, this could end up as a rather large list, too, which takes a while >> to look them up the first time. Considering >> LoggerContext.setConfiguration(Configuration) >> calls this method, it can significantly increase test execution time if you >> don't have an /etc/hosts entry for your computer. >> >> -- >> Matt Sicker <boa...@gmail.com> >> > -- Matt Sicker <boa...@gmail.com>