I don’t want to see logs of third-party librairies when running my tests, because it creates big build reports filled with logs that don’t add any value making difficult to analyse them.

So, to not display the logs of third party librairies, I create a log4j.properties file in my /src/test/resources, with the following policy:

  • by default, set log level to ERROR

  • add exception for logs coming from my project, with log level set to INFO

Here is the content of log4j.properties file. To adapt this file to your project, you can replace fr.vincent.doba by the main package of your project.

log4j.rootCategory=ERROR, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %c{1}: %m%n

log4j.logger.fr.vincent.doba=INFO