title: Using formatter with Logger v/s checking isXEnabled
body: <p>As is well known </p>
  
  <pre><code>LOGGER.debug("The parameter p1 cannot be " + p1 +
          ", it must be between " + P1_MIN + " and " + P1_MAX);
  </code></pre>
  
  <p>Has the disadvantage that string concatenation is done even if the result will be discarded due to logger settings. To avoid this, the following boilerplate is popular</p>
  
  <pre><code>if (LOGGER.isDebugEnabled())
  {
      LOGGER.debug("The parameter p1 cannot be " + p1 +
              ", it must be between " + P1_MIN + " and " + P1_MAX);
  }
  </code></pre>
  
  <p>Which avoids it at the cost of three extra lines. </p>
  
  <p><code>slf4j</code> (and others) offer an <a href="http://www.slf4j.org/apidocs/org/slf4j/Logger.html#debug%28java.lang.String,%20java.lang.Object%5B%5D%29" rel="nofollow">alternative</a> using <code>varargs</code> (and <code>overloading</code>):</p>
  
  <pre><code>    LOGGER.debug("The parameter p1 cannot be {} , it must be between {} and {}", 
               p1, P1_MIN, P1_MAX);
  </code></pre>
  
  <p>This looks much cleaner but there is an <code>Object array</code> getting created to pass variable number of parameters.</p>
  
  <p><strong>How expensive is this object array creation?</strong> Does its cost outweigh the advantage of reducing lines of code?</p>
  
  <p>I suspect the <code>varargs/formatter</code> based methods are created exactly to address the above boilerplate so even though slightly subjective replies from experts will help great many numbers of programmers. Also, IMHO it is not subjective if object array creation is either very cheap (which is my hope) or very expensive. </p>