Disable debug logging when running unit tests

I have a Spock unit test that uses OpenCSV to read in some data. It works fine, but when I run it through IntelliJ (using Gradle to run the tests) there are a whole lot of debug-level logs coming from org.apache.commons.beanutils.*. I would like to turn those off so that any important logs are visible. I poked through the documentation on TestLoggingContainer and tried the below, but I still get the debug logs. What else can I try?

test {
    testLogging {
        debug {
            events "failed"

Your question has absolutely nothing to do with Gradle.
Please consider in the future other communities for questions that are not related to Gradle.
With the testLogging configuration you just configure what Gradle logs about your tests, not what your test code logs.

Your project uses Logback as a logging framework and redirects the logs from the various existing logging apis to that.
As you do not have a Logback configuration file, it defaults to debug logging.
Add a Logback configuration file to src/test/resources that you configure however you want.

Ahh, sorry for the confusion. I thought we’d adjusted some integration test logging at work via Gradle configurations, but I may have misunderstood what was going on. Thank you for the additional direction.

1 Like