title: Logging from default interface methods
body: <p>Salut to all Java gurus!</p>
  
  <p>Since Java8 we can have default implementations in interfaces (yay!).
  However problem arises when you want to log from default method.</p>
  
  <p>I have a feeling that it is not wise to call .getLogger() every time I want to log something in a default method.</p>
  
  <p>Yes, one can define static variable in an interface - but that is not a good practice for interfaces anyway + it exposes the logger (must be public).</p>
  
  <p>Solution I have at the moment:</p>
  
  <pre><code>interface WithTimeout&lt;Action&gt; {
  
      default void onTimeout(Action timedOutAction) {
          LogHolder.LOGGER.info("Action {} time out ignored.", timedOutAction);
      }
  
      static final class LogHolder {
          private static final Logger LOGGER = getLogger(WithTimeout.class);
      }
  }
  </code></pre>
  
  <p>LogHolder is still visible to everybody which doesn't really make any sense since it does not provide any methods and it should be internal to the interface.</p>
  
  <p>Does any of you know about better solution? :)</p>
  
  <p>EDIT: I use SLF4J backed by Logback</p>