5

I want to change the log level for a particular maven plugin, ideally from within the pom.xml, less than ideal but still acceptable by a command line switch.

In particular I want INFO in general but only WARN from maven-shade-plugin:3.1.0.

scravy
  • 11,904
  • 14
  • 72
  • 127
  • Just expanding on this, you're asking how to filter logs from a particular plugin based on the log level, not change the log level of a plugin's messages. – caduceus Nov 15 '22 at 08:03

1 Answers1

3

You can configure it with simplelogger.properties file. Add following line to the properties file located at {maven.home}/conf/logging/simplelogger.properties

org.slf4j.simpleLogger.log.org.apache.maven.plugins.shade=warn

Info level is the default level for all loggers, which is also set at properties file (If you want to change it in the future)

org.slf4j.simpleLogger.defaultLogLevel=info

If you want to do it with command switch you can add following to your maven command. (I prefer modifying properties file)

-Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.shade=warn
miskender
  • 7,460
  • 1
  • 19
  • 23
  • How to get the plugin name ? For example how do I know the plugin name for `org.sonarsource.scanner.maven:sonar-maven-plugin` ? – tuk Nov 08 '22 at 14:45
  • `org.apache.maven.plugins.shade` from the example above is logger name which is usually the java class name of the plugin's classes. You can find this by adding `-Dorg.slf4j.simpleLogger.showLogName=true` to a maven call. So you probably need something like `-Dorg.slf4j.simpleLogger.log.org.sonarsource.scanner.maven=warn`? – Martin Höller Nov 09 '22 at 07:41