[logback-user] Is there a Junit appender?

Robert Elliot rob at lidalia.org.uk
Wed Apr 28 20:22:19 CEST 2010


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.



On 28 Apr 2010, at 19:16, "Chris Helck" <Chris.Helck at us.icap.com> wrote:

> 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?
>
> I am using slf4j. When I run the unit tests I use the NOP logger, in  
> production we use logback.
>
> I want something like:
>
>   Logger logger = LoggerFactory.getLogger(MyStuff.class);
>   logger.info( "Hello World");
>
>   assertTrue( logger.wasLoggedAsInfo( "Hello World"));
>
> Thanks,
> C. Helck
>
>
>
>
>
> **********************************************************************
>
> This communication and all information (including, but not limited to,
>
> market prices/levels and data) contained therein (the "Information")  
> is
>
> for informational purposes only, is confidential, may be legally
>
> privileged and is the intellectual property of ICAP plc and its  
> affiliates
>
> ("ICAP") or third parties. No confidentiality or privilege is waived  
> or
>
> lost by any mistransmission. The Information is not, and should not
>
> be construed as, an offer, bid or solicitation in relation to any
>
> financial instrument or as an official confirmation of any  
> transaction.
>
> The Information is not warranted, including, but not limited, as to
>
> completeness, timeliness or accuracy and is subject to change
>
> without notice. ICAP assumes no liability for use or misuse of the
>
> Information. All representations and warranties are expressly
>
> disclaimed. The Information does not necessarily reflect the views of
>
> ICAP. Access to the Information by anyone else other than the
>
> recipient is unauthorized and any disclosure, copying, distribution or
>
> any action taken or omitted to be taken in reliance on it is  
> prohibited. If
>
> you receive this message in error, please immediately delete it and  
> all
>
> copies of it from your system, destroy any hard copies of it and
>
> notify the sender.
>
> **********************************************************************
>
>
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/logback-user/attachments/20100428/c70186c5/attachment-0001.html>


More information about the Logback-user mailing list