Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1068

"Failed to get local hostname" when lacking network interfaces

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • logback-core
    • None

    Description

      When running an application using logback in a docker container with no networking, we always see the following error printed:

      |-ERROR in ch.qos.logback.core.util.ContextUtil@5858ba4b - Failed to get local hostname java.net.UnknownHostException
      

      From the source, in ContextUtils.java, it looks like this exception is thrown because there are no network interfaces available. This leads to an unavoidable error being shown.

      This is particularly irritating since we don't even use the hostname context values in our log formatters! That suggests that the ideal fix would be to load these values lazily.

      Note that this is not a duplicate of LOGBACK-749, in fact the problematic code was introduced in the fix for that issue, c1e31a89c0380af3883547f5da7799b8157512eb.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            michaelpj Michael Peyton Jones
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: