LogFixture? As illustrated in ExampleTest?

This fixture lets you turn on all or selected loggers for the duration of a 
single test. I used it all the time when debugging. Works great.
It works when turning loggers on when the default is that they are off. For 
whatever reason, I could not get it to work to turn off logging that was 
enabled in the config file.
At one point I did look into adding a custom debug logger that works just like 
System.out, but is disabled by default. That way, conversion was just a matter 
of replacing System.out with TestLogger.out which can be done via 
search/replace. Not sure if IĀ ever checked that in, but it would be trivial to 
replicate.
Thanks,
- Paul

 

    On Thursday, May 24, 2018, 5:32:49 PM PDT, Timothy Farkas 
<tfar...@mapr.com> wrote:  
 
 Hi All,

I was wondering if there was a magical way to enable the Slf4j loggers for unit 
tests without adding a logback-test.xml file into src/test/resources for a 
submodule in the project? If not, would there by any issues with adding a 
default logback-test.xml file that has logging disabled by default to each 
submodule's src/test/resources directory? I'd like to do this in order to 
discourage the use of System.out.println in tests (and eventually prohibit it 
completely) by providing an easy to use out of the box alternative. Currently 
our test logs are polluted by many System.out.print statements and switching to 
using logging will allow us to have our test messages when we want them, and to 
disable them when we don't want them.

Thanks,
Tim  

Reply via email to