JacocoReport and log4j-2 integration

We are trying to upgrade log4j to log4j2 in our codebase. Everything works except generating jacocoReports. The task is below:

task jacocoBuildModuleTestReports(type: JacocoReport) {
dependsOn ':jacocoMergeAllTestResults’
executionData file("$rootDir/build/jacoco/allTests.exec")
sourceSets sourceSets.main

 reports {
     xml.enabled false
     csv {
         enabled true
         destination "$reportsDir/jacoco/module/csv/jacocoModuleTestReport.csv"
     html {
         destination "$reportsDir/jacoco/module/html"


We are using jacoco verison Without the log4j2 updates the task finishes within a few seconds. But will log4j2 changes, the build eventually finishes but generating the report takes minutes in every module. We tried running in info and debug but there wasn’t enough logging for the jacoco ant task to figure out what root cause of the issue.

We did add the following log4j configuration file location to the compiler fork options:
jvmArgs = [’-XX:MaxPermSize=1g’, ‘-XX:+UseConcMarkSweepGC’, ‘-XX:+ParallelRefProcEnabled’,
’-XX:+PerfDisableSharedMem’, “-Dlog4j.configurationFile=$rootDir/log4j2-compile.xml”.toString()]

And updated the tests jvmArgs to:
jvmArgs = [’-XX:MaxPermSize=2g’, ‘-XX:+PerfDisableSharedMem’, “-Dlog4j.configurationFile=$rootDir/log4j2-test.xml”.toString()]

Has anyone run into issues with log4j2 and Jacoco?