'Cannot set readonly property: level for class: org.gradle.internal.logging.services.DefaultLoggingManager in gradle

I have a gradle task as follows which is throwing the below error while running:

Cannot set readonly property: level for class: org.gradle.internal.logging.services.DefaultLoggingManager

task swaggerGenerator(type: JavaExec) {
    doFirst {
        mkdir "$buildDir/api"
    }
    main = "xyz"
    classpath = sourceSets.test.runtimeClasspath
    logging.level = "ERROR"
}

Gradle version being used is 7.3.3



Solution 1:[1]

I removed the logging.level line from the gradle task to get rid of this error.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abhilash