[logback-user] Is there a Junit appender?
Chris Helck
Chris.Helck at us.icap.com
Wed Apr 28 22:27:35 CEST 2010
Is there a way to do the equivilent of LoggingContext.reset() from a config file? The module I'm working in has hundreds of tests, I'd hate to have to add reset() to each file.
Thanks,
Chris
-----Original Message-----
From: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch] On Behalf Of Ceki Gülcü
Sent: Wednesday, April 28, 2010 3:31 PM
To: logback users list
Subject: Re: [logback-user] Is there a Junit appender?
On 28/04/2010 9:10 PM, Chris Helck wrote:
> Thanks, this seems to be what I'm looking for, but I'm having a few problems.
>
> 1. I've checked the source code and I only see ListAppender being used in AppenderTrackerTest and StringListAppender. You said it's is used extensively, am I missing something?
You should also look in logback-classic not just logback-core.
> 2. Below is my code. It seems to work, but now the tests are echo'ing all log messages to stdout. Prior to this change the messages were going to SLF4j's NOP binding. I suspect this is because the Logback classic jar is on the classpath and is getting picked up. Long story short, I don't want log messages echo'd to stdout when running tests. Any ideas?
That's the default logback configuration kicking in. You can either create a LoggingContext per unit test, which is what logback's own unit tests do, or reset the default logger context, the one returned by LoggerFactory. Here is the code to reset the default logger context.
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
lc.reset();
--
Ceki
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://qos.ch/mailman/listinfo/logback-user
**********************************************************************
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.
**********************************************************************
More information about the Logback-user
mailing list