Skip to content

Commit

Permalink
waffle
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin King committed Nov 18, 2009
1 parent bb9028a commit c2c3d56
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions reference/en-US/extensions.xml
Expand Up @@ -35,15 +35,9 @@ public class Checkout {
}]]></programlisting>

<para>
The example shows how objects can be interpolated into a message. This interpolation is done using
<emphasis>java.text.MessageFormat</emphasis>, so see the JavaDoc for that class for more details. In this case,
the <literal>ShoppingCart</literal> should have implemented the <emphasis>toString()</emphasis> method to
produce a human readable value that is meaningful in messages. Normally, this call would have involved
evaluating cart.toString() with String concatenation to produce a single String argument. Thus it was necessary
to surround the call with an if-statement using the condition <emphasis>log.isDebugEnabled()</emphasis> to
avoid the expensive String concatenation if the message was not actually going to be used. However, when using
<literal>@Logger</literal>-injected logging, the conditional test can be left out since the object arguments
are not evaluated unless the message is going to be logged.
The example shows how objects can be interpolated into a message. If you use this approach, you do not need to
surround a call to the logger with a condition like <emphasis>if ( log.isDebugEnabled() )</emphasis> to
avoid string concatenation.
</para>

<note>
Expand Down

0 comments on commit c2c3d56

Please sign in to comment.