When I am testing my class, application writes lots of stuff to the console, because of logging (I am using SLF4J). How do I disable logging in this case, without introducing special flag inside tested class?
1 Answer
SLF4J is only a facade, meaning that it does not provide a complete logging solution, so if you are using it with LOG4J just change your logging level to OFF. For more info see https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html#OFF
So you can have two log4j.xml configuration files, one for production and one for testing with logging level set to OFF or better to WARN.
-
Which, in turn, means, that my tests become implementation-dependent. Or I should introduce something like TestLoggerManager with static methods in it. Commented Jun 3, 2014 at 12:33