title: How to improve logging mechanism with Java8s lambdas
body: <p>How is it possible, to improve your logging mechanism, by not having the overhead of string concatenations?</p>
  
  <p>Consider the following example:</p>
  
  <pre><code>import java.util.logging.Level;
  import java.util.logging.Logger;
  
  public class LoggerTest {
      public static void main(String[] args) {
          // get logger
          Logger log = Logger.getLogger(LoggerTest.class.getName());
  
          // set log level to INFO (so fine will not be logged)
          log.setLevel(Level.INFO);
  
          // this line won't log anything, but will evaluate the getValue method
          log.fine("Trace value: " + getValue());
      }
  
      // example method to get a value with a lot of string concatenation
      private static String getValue() {
          String val = "";
  
          for (int i = 0; i &lt; 1000; i++) {
              val += "foo";
          }
  
          return val;
      }
  }
  </code></pre>
  
  <p>The log method <code>log.fine(...)</code> will not log anything, because the log level is set to <code>INFO</code>. The problem is, that the method <code>getValue</code> will be evaluated anyway.</p>
  
  <p>And this is a big performance issue in big applications with a lot of debug statements.</p>
  
  <p>So, how to solve this problem?</p>