<html><body bgcolor="#FFFFFF"><div>Logback has a list appender that just stores all logging events in a list that you can query. That's what I use for unit testing logging.<br><br><div><br></div></div><div><br>On 28 Apr 2010, at 19:16, "Chris Helck" &lt;<a href="mailto:Chris.Helck@us.icap.com">Chris.Helck@us.icap.com</a>&gt; wrote:<br><br></div><div></div><blockquote type="cite"><div>

<!-- Converted from text/rtf format -->

<p><font size="2" face="Arial">I want to unit test some objects and to check that the objects are logging certain messages under certain cirmcumstances. Is this possible? Is it easy?</font></p>

<p><font size="2" face="Arial">I am using slf4j. When I run the unit tests I use the NOP logger, in production we use logback. </font>
</p>

<p><font size="2" face="Arial">I want something like:</font>
</p>

<p><font size="2" face="Arial">&nbsp; Logger logger = LoggerFactory.getLogger(MyStuff.class);</font>

<br><font size="2" face="Arial">&nbsp; <a href="http://logger.info">logger.info</a>( "Hello World");</font>
</p>

<p><font size="2" face="Arial">&nbsp; assertTrue( logger.wasLoggedAsInfo( "Hello World"));</font>
</p>

<p><font size="2" face="Arial">Thanks,</font>

<br><font size="2" face="Arial">C. Helck</font>
</p>
<br>
<br>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</p>


<p><span style="font-family:'Arial';font-size:8pt;">**********************************************************************</span></p>
<p><span style="font-family:'Arial';font-size:8pt;">This communication and all information (including, but not limited to,</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> market prices/levels and data) contained therein (the "Information") is</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> for informational purposes only, is confidential, may be legally</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> privileged and is the intellectual property of ICAP plc and its affiliates</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> ("ICAP") or third parties. No confidentiality or privilege is waived or</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> lost by any mistransmission. The Information is not, and should not</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> be construed as, an offer, bid or solicitation in relation to any</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> financial instrument or as an official confirmation of any transaction.</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> The Information is not warranted, including, but not limited, as to</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> completeness, timeliness or accuracy and is subject to change</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> without notice. ICAP assumes no liability for use or misuse of the</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> Information. All representations and warranties are expressly</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> disclaimed. The Information does not necessarily reflect the views of</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> ICAP. Access to the Information by anyone else other than the</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> recipient is unauthorized and any disclosure, copying, distribution or</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> any action taken or omitted to be taken in reliance on it is prohibited. If</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> you receive this message in error, please immediately delete it and all</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> copies of it from your system, destroy any hard copies of it and</span></p>
<p><span style="font-family:'Arial';font-size:8pt;"> notify the sender.</span></p>
<p><span style="font-family:'Arial';font-size:8pt;">**********************************************************************</span></p>
<p><span style="font-family:'Arial';font-size:8pt;">&nbsp;</span></p>

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Logback-user mailing list</span><br><span><a href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a></span><br><span><a href="http://qos.ch/mailman/listinfo/logback-user">http://qos.ch/mailman/listinfo/logback-user</a></span><br></div></blockquote></body></html>