[Tiny] Gradle, Show Me the Test Logs!
Petr Filaretov

Petr Filaretov @pfilaretov42

About: Passionate software engineer who is always striving for excellence.

Joined:
Sep 1, 2022

[Tiny] Gradle, Show Me the Test Logs!

Publish Date: Mar 7
0 0

This week, I learned how to enable logging output for Gradle's test task.

Why did I need it?

I created a couple of tests and added some logging. I ran the tests one by one in IntelliJ IDEA and checked the logs. Then, I ran gradle build and... there were no logs from the tests in the output 🧐

So, if you, like me, are wondering "Where are my logs?", here's how to enable logging during the Gradle build.

Set the showStandardStreams property in the build.gradle file:

test {
    testLogging.showStandardStreams = true
}
Enter fullscreen mode Exit fullscreen mode

This will give you logs split by test classes and test methods.

If you don't want that split and just want the logs in order of appearance, the following should do the trick:

test {
    onOutput { descriptor, event ->
        logger.lifecycle(event.message)
    }
}
Enter fullscreen mode Exit fullscreen mode

Dream your code, code your dream.

Comments 0 total

    Add comment