You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Debraj Manna <su...@gmail.com> on 2022/11/08 17:22:40 UTC

Change log level of a maven plugin

I want to disable the sonar analysis logs during mvn test coming from the
below plugin.

<plugin>
  <groupId>org.sonarsource.scanner.maven</groupId>
  <artifactId>sonar-maven-plugin</artifactId>
  <version>3.9.1.2184</version>

</plugin>

As per this discussion
<https://community.sonarsource.com/t/turn-off-console-logging-sonar-log-level/45771/3?u=tuk>
sonar does not support this. So I tried the solution suggested here
<https://stackoverflow.com/a/49035439/785523> to change log level of a
maven plugin by passing
-Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.sonar=warn with mvn
test. But it is not working and I am still seeing INFO logs like below

2022-11-08T15:51:02.8677442Z [INFO] Sensor SurefireSensor [java]
2022-11-08T15:51:02.8678035Z [INFO] parsing
[/codebuild/output/src270901131/src/
github.com/Spotnana-Tech/spotnana/src/java/back-office/target/surefire-reports
]
2022-11-08T15:51:02.8678621Z [INFO] Sensor SurefireSensor [java] (done) |
time=41ms

I know the above question is not directly related to maven. But if anyone
has any suggestions it is welcome.

Re: Change log level of a maven plugin

Posted by Debraj Manna <su...@gmail.com>.
On running mvn with -Dorg.slf4j.simpleLogger.showLogName=true it showed 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 maven with
-Dorg.slf4j.simpleLogger.log.org.sonarsource.scanner.maven.SonarQubeMojo=error
it changed the log level.

On Tue, Nov 8, 2022 at 11:43 PM Debraj Manna <su...@gmail.com>
wrote:

> Thanks Slawomir. I was also searching how to get the logger name for sonar
> plugin. Trying it.
>
> On Tue, Nov 8, 2022 at 11:12 PM Slawomir Jaranowski <
> s.jaranowski@gmail.com> wrote:
>
>> Hi,
>>
>> You must pass such parameters as systeem properties
>>
>> First you must discover logger name of sonar plugin, so
>>
>> MAVEN_OPTS=-Dorg.slf4j.simpleLogger.showLogName=true mvn ...
>>
>> next
>>
>> MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.<sonar loger name>=error mvn ...
>>
>> <sonar loger name> - must be replaced by propper logger name from the
>> first
>> test.
>>
>> it will be working only if sonar plugin use logger in proper way
>>
>> finally you can create file in project: .mvn/jvm.config with  line:
>> -Dorg.slf4j.simpleLogger.log.<sonar loger name>=error
>>
>>
>>
>> wt., 8 lis 2022 o 18:23 Debraj Manna <su...@gmail.com>
>> napisał(a):
>>
>> > I want to disable the sonar analysis logs during mvn test coming from
>> the
>> > below plugin.
>> >
>> > <plugin>
>> >   <groupId>org.sonarsource.scanner.maven</groupId>
>> >   <artifactId>sonar-maven-plugin</artifactId>
>> >   <version>3.9.1.2184</version>
>> >
>> > </plugin>
>> >
>> > As per this discussion
>> > <
>> >
>> https://community.sonarsource.com/t/turn-off-console-logging-sonar-log-level/45771/3?u=tuk
>> > >
>> > sonar does not support this. So I tried the solution suggested here
>> > <https://stackoverflow.com/a/49035439/785523> to change log level of a
>> > maven plugin by passing
>> > -Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.sonar=warn with
>> mvn
>> > test. But it is not working and I am still seeing INFO logs like below
>> >
>> > 2022-11-08T15:51:02.8677442Z [INFO] Sensor SurefireSensor [java]
>> > 2022-11-08T15:51:02.8678035Z [INFO] parsing
>> > [/codebuild/output/src270901131/src/
>> >
>> >
>> github.com/Spotnana-Tech/spotnana/src/java/back-office/target/surefire-reports
>> > ]
>> > 2022-11-08T15:51:02.8678621Z [INFO] Sensor SurefireSensor [java] (done)
>> |
>> > time=41ms
>> >
>> > I know the above question is not directly related to maven. But if
>> anyone
>> > has any suggestions it is welcome.
>> >
>>
>>
>> --
>> Sławomir Jaranowski
>>
>

Re: Change log level of a maven plugin

Posted by Debraj Manna <su...@gmail.com>.
Thanks Slawomir. I was also searching how to get the logger name for sonar
plugin. Trying it.

On Tue, Nov 8, 2022 at 11:12 PM Slawomir Jaranowski <s....@gmail.com>
wrote:

> Hi,
>
> You must pass such parameters as systeem properties
>
> First you must discover logger name of sonar plugin, so
>
> MAVEN_OPTS=-Dorg.slf4j.simpleLogger.showLogName=true mvn ...
>
> next
>
> MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.<sonar loger name>=error mvn ...
>
> <sonar loger name> - must be replaced by propper logger name from the first
> test.
>
> it will be working only if sonar plugin use logger in proper way
>
> finally you can create file in project: .mvn/jvm.config with  line:
> -Dorg.slf4j.simpleLogger.log.<sonar loger name>=error
>
>
>
> wt., 8 lis 2022 o 18:23 Debraj Manna <su...@gmail.com>
> napisał(a):
>
> > I want to disable the sonar analysis logs during mvn test coming from the
> > below plugin.
> >
> > <plugin>
> >   <groupId>org.sonarsource.scanner.maven</groupId>
> >   <artifactId>sonar-maven-plugin</artifactId>
> >   <version>3.9.1.2184</version>
> >
> > </plugin>
> >
> > As per this discussion
> > <
> >
> https://community.sonarsource.com/t/turn-off-console-logging-sonar-log-level/45771/3?u=tuk
> > >
> > sonar does not support this. So I tried the solution suggested here
> > <https://stackoverflow.com/a/49035439/785523> to change log level of a
> > maven plugin by passing
> > -Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.sonar=warn with mvn
> > test. But it is not working and I am still seeing INFO logs like below
> >
> > 2022-11-08T15:51:02.8677442Z [INFO] Sensor SurefireSensor [java]
> > 2022-11-08T15:51:02.8678035Z [INFO] parsing
> > [/codebuild/output/src270901131/src/
> >
> >
> github.com/Spotnana-Tech/spotnana/src/java/back-office/target/surefire-reports
> > ]
> > 2022-11-08T15:51:02.8678621Z [INFO] Sensor SurefireSensor [java] (done) |
> > time=41ms
> >
> > I know the above question is not directly related to maven. But if anyone
> > has any suggestions it is welcome.
> >
>
>
> --
> Sławomir Jaranowski
>

Re: Change log level of a maven plugin

Posted by Slawomir Jaranowski <s....@gmail.com>.
Hi,

You must pass such parameters as systeem properties

First you must discover logger name of sonar plugin, so

MAVEN_OPTS=-Dorg.slf4j.simpleLogger.showLogName=true mvn ...

next

MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.<sonar loger name>=error mvn ...

<sonar loger name> - must be replaced by propper logger name from the first
test.

it will be working only if sonar plugin use logger in proper way

finally you can create file in project: .mvn/jvm.config with  line:
-Dorg.slf4j.simpleLogger.log.<sonar loger name>=error



wt., 8 lis 2022 o 18:23 Debraj Manna <su...@gmail.com> napisał(a):

> I want to disable the sonar analysis logs during mvn test coming from the
> below plugin.
>
> <plugin>
>   <groupId>org.sonarsource.scanner.maven</groupId>
>   <artifactId>sonar-maven-plugin</artifactId>
>   <version>3.9.1.2184</version>
>
> </plugin>
>
> As per this discussion
> <
> https://community.sonarsource.com/t/turn-off-console-logging-sonar-log-level/45771/3?u=tuk
> >
> sonar does not support this. So I tried the solution suggested here
> <https://stackoverflow.com/a/49035439/785523> to change log level of a
> maven plugin by passing
> -Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.sonar=warn with mvn
> test. But it is not working and I am still seeing INFO logs like below
>
> 2022-11-08T15:51:02.8677442Z [INFO] Sensor SurefireSensor [java]
> 2022-11-08T15:51:02.8678035Z [INFO] parsing
> [/codebuild/output/src270901131/src/
>
> github.com/Spotnana-Tech/spotnana/src/java/back-office/target/surefire-reports
> ]
> 2022-11-08T15:51:02.8678621Z [INFO] Sensor SurefireSensor [java] (done) |
> time=41ms
>
> I know the above question is not directly related to maven. But if anyone
> has any suggestions it is welcome.
>


-- 
Sławomir Jaranowski