Yes, remember that one of the overridden info methods is info (String msg, String[] args). In your first test you used this version of the method, which did exactly as you instructed and wrote out the first argument in the array in the first replacement position. If you want it to treat the array as a single argument try <a href="http://log.info">log.info</a>("Just the array <{}>", (Object)array); <div>
(*Chris*)<br><br><div class="gmail_quote">On Thu, Nov 10, 2011 at 10:59 AM, Colin Ingarfield <span dir="ltr"><<a href="mailto:colini@alumni.utexas.net">colini@alumni.utexas.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello,<br>
<br>
Today I noticed that slf4j/logback sometimes logs the entire contents of an array and sometimes just logs the first element. Here is a test app:<br>
<br>
public class LogbackTest {<br>
protected static final Logger log = LoggerFactory.getLogger(<u></u>LogbackTest.class);<br>
<br>
public static final void main(String[] args) {<br>
String[] array = {"one", "two", "three"};<br>
<br>
<a href="http://log.info" target="_blank">log.info</a>("Just the array <{}>", array);<br>
<a href="http://log.info" target="_blank">log.info</a>("a var then the array {} <{}>", 10, array);<br>
<a href="http://log.info" target="_blank">log.info</a>("the array <{}> then a var {}", array, 10);<br>
}<br>
}<br>
<br>
The output I get is:<br>
12:54:19.366 [main] INFO c.l.n.m.LogbackTest - Just the array <one><br>
12:54:19.372 [main] INFO c.l.n.m.LogbackTest - a var then the array 10 <[one, two, three]><br>
12:56:52.497 [main] INFO c.l.n.m.LogbackTest - the array <[one, two, three]> then a var 10<br>
<br>
When there is a single "{}" placeholder only the first element of the array is output. When there are two placeholders all the elements are output.<br>
<br>
This is slf4j 1.6.1 and logback classic/core 0.9.27.<br>
<br>
Is this the expected behavior?<br>
<br>
thanks,<br>
Colin<br>
______________________________<u></u>_________________<br>
slf4j-user mailing list<br>
<a href="mailto:slf4j-user@qos.ch" target="_blank">slf4j-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-user" target="_blank">http://mailman.qos.ch/mailman/<u></u>listinfo/slf4j-user</a><br>
</blockquote></div><br></div>