I'm in the process of migrating my tests to use Junit5 and I noticed that somehow my logs stopped working. Before I was defining my logs with a simple simplelogger.properties inside by test/resources folder.
But this no longer working. I was reading the gradle documentation and I see a lot of information about it and I can define some logs using the test logging container. Anyway this somehow does not seem to allow me to do what I want.
I'm looking if there is anything I can add to my test definition that let's me define the log4j configuration folder/file
test {
useJUnitPlatform()
maxHeapSize = '2G'
reports {
junitXml.enabled = true
html.enabled = true
}
timeout = Duration.ofMinutes(30)
testLogging {
showStandardStreams true
exceptionFormat 'full'
events "PASSED", "SKIPPED", "FAILED", "STANDARD_OUT", "STANDARD_ERROR"
}
systemProperty 'bla', 'bla'
}
Is there a way I can define a log4.properties file or a simplelogger.properties file and tell the jvm where to find it but instead of using the JVM parameters I would use some gradle configuration?
Also I notice when my tests start that it finds multiple SLF4J bindings which I'm not sure how to work around.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/.gradle/caches/7.4.2/generated-gradle-jars/gradle-api-7.4.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.11/4741689214e9d1e8408b206506cbe76d1c6a7d60/logback-classic-1.2.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.30/c21f55139d8141d2231214fb1feaf50a1edca95e/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.gradle.internal.logging.slf4j.OutputEventListenerBackedLoggerContext]
Is there any good documentation for this? I seem to not find what I need in the official documentation or examples.
The source of the problem might be something like this (i'm using the gradle-groovy plugin also): SLF4J: multiple SLF4J bindings with Gradle Plugin
if nothing else works I'm thinking of trying something like this (to override it on the jvm args): How to pass args to JVM which runs tests with Gradle