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
}
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)
}
}
Dream your code, code your dream.
Top comments (0)