Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce log level in Sonar 2.1.x

I have a Maven 3.x build that uses Sonar 2.1.x for quality control. The maven-sonar plugin is used from inside Jenkins to run the Sonar checks. During the Jenkins build, when Sonar kicks in, it logs A LOT of not so useful information at INFO level:

[INFO] [15:29:14.195] Java version: 1.6
[INFO] [15:29:20.853] Execute PMD 4.3 done: 6658 ms
[INFO] [15:29:20.853] Sensor PmdSensor done: 6658 ms
[INFO] [15:29:20.854] Sensor ProfileSensor...
[INFO] [15:29:21.186] Sensor ProfileSensor done: 332 ms
[INFO] [15:29:21.187] Sensor ProfileEventsSensor...
[INFO] [15:29:21.190] Sensor ProfileEventsSensor done: 3 ms
[INFO] [15:29:21.190] Sensor ProjectLinksSensor...
[INFO] [15:29:21.192] Sensor ProjectLinksSensor done: 2 ms
[INFO] [15:29:21.192] Sensor VersionEventsSensor...
[INFO] [15:29:21.198] Sensor VersionEventsSensor done: 6 ms
[INFO] [15:29:21.198] Sensor Maven dependencies...
[INFO] [15:29:21.261] Sensor Maven dependencies done: 63 ms
...

The log is quite big. I have been trying to find a way to set the log level to WARN with no luck. Any idea?

Thanks!

like image 805
Luciano Fiandesio Avatar asked Sep 01 '25 05:09

Luciano Fiandesio


2 Answers

Unfortunately, there's no way to mute this INFO-level log.

like image 69
Fabrice - SonarSource Team Avatar answered Sep 03 '25 00:09

Fabrice - SonarSource Team


As discussed here log level can be changed at the maven plugin level.

Run mvn with -Dorg.slf4j.simpleLogger.showLogName=true it will show the logger name with log like below

2022-11-09T05:47:18.8604059Z [INFO] org.sonarsource.scanner.maven.SonarQubeMojo - SCM writing changed lines (done) | time=83ms
2022-11-09T05:47:18.8604819Z [INFO] org.sonarsource.scanner.maven.SonarQubeMojo - Analysis report generated in 287ms, dir size=5.2 MB
2022-11-09T05:47:18.8605606Z [INFO] org.sonarsource.scanner.maven.SonarQubeMojo - Analysis report compressed in 1993ms, zip size=4.1 MB
2022-11-09T05:47:18.8606333Z [INFO] org.sonarsource.scanner.maven.SonarQubeMojo - Analysis report uploaded in 282ms

then on executing mvn with -Dorg.slf4j.simpleLogger.log.org.sonarsource.scanner.maven.SonarQubeMojo=error it will change the log level.

like image 31
tuk Avatar answered Sep 03 '25 00:09

tuk