5

I'm using SonarQube plugin (version 2.6.1) for Gradle (version 4.7) and have the problem that a lot of unimportant log output is being written while running the sonar analysis on my CI server.

Is there a way to fine-tune the log level for this plugin?

I checked the documentation but the only setting related to the log output I found was the JVM argument "verbose" which I'm not using either way (I guess the default is false so this shouldn't be turned on for me).

EDIT: Here are some examples of the output I would like to get rid of:

  1. Some huge exception stacktraces during findbugs analysis (this one is shortened, didn't want to post the whole stacktrace, it's really huge).
16:23:34.993 ERROR - Unable to create symbol table for : /opt/workspace/pipeline-1/src/main/java/com/SomeClass.java
java.lang.NullPointerException: null
    at org.sonar.java.resolve.TypeAndReferenceSolver.getSymbolOfMemberSelectExpression(TypeAndReferenceSolver.java:232) ~[java-squid-2.5.1.jar:na]
    at org.sonar.java.resolve.TypeAndReferenceSolver.resolveAs(TypeAndReferenceSolver.java:200) ~[java-squid-2.5.1.jar:na]
    at org.sonar.java.resolve.TypeAndReferenceSolver.resolveAs(TypeAndReferenceSolver.java:182) ~[java-squid-2.5.1.jar:na]
    at...
  1. Stacktraces from PMD:
16:23:37.206 ERROR - Fail to execute PMD. Following file is ignored: /opt/workspace/pipeline-1/src/main/java/com/SomeClass.java
java.lang.RuntimeException: null
    at org.objectweb.asm.MethodVisitor.visitParameter(Unknown Source) ~[asm-5.0.3.jar:5.0.3]
    at org.objectweb.asm.ClassReader.b(Unknown Source) ~[asm-5.0.3.jar:5.0.3]
    at org.objectweb.asm.ClassReader.accept(Unknown Source) ~[asm-5.0.3.jar:5.0.3]
    at org.objectweb.asm.ClassReader.accept(Unknown Source) ~[asm-5.0.3.jar:5.0.3]
    at net.sourceforge.pmd.lang.java.typeresolution.PMDASMClassLoader.getImportedClasses(PMDASMClassLoader.java:77) ~[pmd-java-5.2.1.jar:na]...
  1. Lots of irrelevant warnings like these:
16:23:38.638 WARN  - /opt/workspace/pipeline-1/src/main/java/com/SomeClass.java: Got an exception - expecting EOF, found '}'
/opt/workspace/pipeline-1/src/main/java/com/SomeClass.java:28:5: expecting RCURLY, found 'default'
16:23:38.655 WARN  - /opt/workspace/pipeline-1/src/main/java/com/SomeClass.java: Got an exception - expecting EOF, found 'someVariable'

I don't know what exactly is causing these problems, but since both my app and the results of the sonar analysis are looking OK, I would like to get rid of those log outputs since they only pollute my logs on Jenkins and make them unreadable.

Marko Previsic
  • 1,820
  • 16
  • 30

1 Answers1

0

There's property sonar.log.level and sonar.verbose; for example:

allprojects {
    sonarqube {
        properties {
            // property "sonar.log.level", "INFO"
            property "sonar.log.level", "TRACE"
        }
    }
}

see the analysis parameters.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • This won't help me. As you may have noticed, some of those logs I'd like to get rid of have ERROR log level. It's too risky to remove **all** ERROR logs by setting the log level above ERROR (e.g. to SEVERE if that's possible). It might bight me down the road if I do this and I need more fine-grained control. – Marko Previsic Jun 25 '19 at 11:25
  • @mprev0 you could still add a Gradle [Exec](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Exec.html) task, which runs a shell script, that removes certain lines from the log-file by pattern matching. don't think one can change the logging behavior much, unless being able to change the plugin code. – Martin Zeitler Jun 25 '19 at 17:47
  • this is not an option at all. I don't want to see those logs in the Jenkins real-time console output either... – Marko Previsic Jun 25 '19 at 21:09