Need to disable log4j output to console during jUnit tests running but all other log4j output should be enable. There are lot exceptions during testing while checking method reaction on incorrect argument, so exception is ok.
Create a new log4j properties file called e.g. log4j-test.properties
with logging disabled. In your surefire config in the POM, add argLine
with -Dlog4j.configuration=log4j-test.properties
.
I know this question is quite old, but still relevant in my opinion, so I'll add an alternative answer.
If you just want to disable (or reduce) logging for certain tests, or for some reason want to do it from code rather than creating a config file, you could do the following:
RootLogger.getRootLogger().setLevel(Level.OFF);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With