142

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?

1
  • 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.
    – VonC
    May 13, 2019 at 18:44

8 Answers 8

173

You can try the -q switch.

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

6
  • 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 9, 2013 at 20:54
  • 23
    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, 2016 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 6, 2016 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, 2017 at 12:44
  • if you are inclined I've submitted a proposed solution compatible with interactive mode issues.apache.org/jira/browse/MNG-6605 , github.com/apache/maven/pull/239
    – Ray
    Mar 28, 2019 at 1:18
40

-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.

1
  • it is used for non-interactive mode, which helps when automating runs
    – Stanislav
    Feb 26, 2018 at 16:30
34

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.

1
  • This solution suppresses upload messages as well as downloads, which is usually not desired in a deploy task
    – Hilikus
    Jun 12, 2020 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.

0
7

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

5

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.)

0
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
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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.