145

Maven spews out far too many lines of output to my taste (I like the Unix way: no news is good news).

I want to get rid of all [INFO] lines, but I couldn't find any mention of an argument or config settings that controls the verbosity of Maven.

Is there no LOG4J-like way to set the log level?

Asaf Bartov
  • 2,711
  • 3
  • 20
  • 18
  • 5
    With Maven 3.6.1 (April 2019, 10+ years later), `mvn --no-transfer-progress ...` (or `mvn -ntp` for shorts) should be an adequate solution. See [my answer below](https://stackoverflow.com/a/56118170/6309). – VonC May 13 '19 at 18:44

8 Answers8

177

You can try the -q switch.

-q,--quiet Quiet output - only show errors

Jorge Ferreira
  • 96,051
  • 25
  • 122
  • 132
  • 2
    @sheki: To clarify, this option does not disable logger debug messages - you need turn that off via your logger settings. For example, if you're using logback, including a src/test/resources/logback-test.xml file in your project will let you customize your logging level to 'off' during the test phase. This will clean everything up. – codeturner May 09 '13 at 20:54
  • 25
    My problem is that `-q` is too quiet. I'm running maven under CI, and I want to see the steps it takes (to track progress), but the download indicators are making mess of the non-ANSI display. Is there a way to only turn off the download progress indicators? – Guss Sep 18 '16 at 11:51
  • 6
    @Guss: If you only want the Downloading/Downloaded messages to go away, use `-B` to enable batch mode (you should have that in your CI system anyways!), and then set `MAVEN_OPTS="-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"` to kill the progress information for the downloads. – ankon Dec 06 '16 at 18:21
  • 2
    In maven 3.5.x I actually need to enable `--batch-mode` (`-B`) for the `-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn` trick to work. – Auke Oct 20 '17 at 12:44
  • if you are inclined I've submitted a proposed solution compatible with interactive mode https://issues.apache.org/jira/browse/MNG-6605 , https://github.com/apache/maven/pull/239 – Ray Mar 28 '19 at 01:18
  • `-q` *kind of* works here (mvn 3.6.0, java 11.0.6) . Unfortunately I still get warnings like this: `WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.` etc. – user1511417 Apr 14 '20 at 11:17
42

-q as said above is what you need. An alternative could be:

-B,--batch-mode Run in non-interactive (batch) mode Batch mode is essential if you need to run Maven in a non-interactive, continuous integration environment. When running in non-interactive mode, Maven will never stop to accept input from the user. Instead, it will use sensible default values when it requires input.

And will also reduce the output messages more or less to the essentials.

Stanislav
  • 2,629
  • 1
  • 29
  • 38
37

My problem is that -q is too quiet. I'm running maven under CI

With Maven 3.6.1 (April 2019), you now have an option to suppress the transfer progress when downloading/uploading in interactive mode.

mvn --no-transfer-progress ....

or in short:

mvn -ntp ... ....

That is what Ray proposed in the comments with MNG-6605 and PR 239.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    This solution suppresses upload messages as well as downloads, which is usually not desired in a `deploy` task – Hilikus Jun 12 '20 at 17:10
26

Official link : https://maven.apache.org/maven-logging.html

You can add in the JVM parameters :

-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN

Beware of UPPERCASE.

jgrtalk
  • 261
  • 3
  • 4
7

Use the -q or --quiet command-line options

Sietse
  • 7,884
  • 12
  • 51
  • 65
6

If you only want to get rid of the [INFO] messages you also could do:

mvn ... | fgrep -v "[INFO]"

To suppress all outputs (except errors) you could redirect stdout to /dev/null with:

mvn ... 1>/dev/null

(This only works if you use bash (or similar shells) to run the Maven commands.)

m13r
  • 2,458
  • 2
  • 29
  • 39
3

The existing answer help you filter based on the log-level using --quiet. I found that many INFO messages are useful for debugging, however the downloading artifact log messages such as the following were noisy and not helpful.

Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml

I found this solution:

https://blogs.itemis.com/en/in-a-nutshell-removing-artifact-messages-from-maven-log-output

mvn clean install -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
curious_prism
  • 349
  • 1
  • 5
1

Maven 3.1.x uses SLF4j for logging, you can find instructions how to configure it at https://maven.apache.org/maven-logging.html

In short: Either modify ${MAVEN_HOME}/conf/logging/simplelogger.properties, or set the same properties via the MAVEN_OPTS environment variable.

For example: setting MAVEN_OPTS to -Dorg.slf4j.simpleLogger.log.org.apache.maven.cl‌​i.transfer.Slf4jMave‌​nTransferListener=wa‌​rn configures the logging of the batch mode transfer listener, and -Dorg.slf4j.simpleLogger.defaultLogLevel=warn sets the default log level.

ankon
  • 4,128
  • 2
  • 26
  • 26