Can I turn off logging in SLF4J SimpleLogger?

I am using SLF4J SimpleLogger for unit tests. Due to external factors, it would be difficult to change magazine providers.

The test class captures the logger from its own structure for recording errors. The problem is that when I test the error condition, I end up with a big scary error message in the test logs, although the test passes. I think this is a bad thing.

When I used Log4J, I could grab the logger for the tested class and change its level to OFF before running the test, and then change it. It seems that SimpleLogger does not have an OFF level, so the quietest value will be ERROR, which, of course, is logged when called error().

Is there a better way to do this? Is it possible?

+4
source share
1 answer

According to https://jira.qos.ch/browse/SLF4J-332 and https://www.slf4j.org/news.html SLF4J 1.7.22 added support for the OFF level in SimpleLogger.

+1
source

Source: https://habr.com/ru/post/1531350/


All Articles