Asaf Bartov
Asaf Bartov

Reputation: 2810

Can Maven be made less verbose?

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?

Upvotes: 153

Views: 74302

Answers (9)

Lukas Eder
Lukas Eder

Reputation: 221145

I've been successful in the past to mute individual warnings e.g. for com.example.X, by using this plugin configuration:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0.0</version>
    <executions>
        <execution>
            <phase>initialize</phase>
            <goals>
                <goal>set-system-properties</goal>
            </goals>
            <configuration>
                <properties>
                    <property>
                        <name>org.slf4j.simpleLogger.log.com.example.X</name>
                        <value>error</value>
                    </property>
                </properties>
            </configuration>
        </execution>
    </executions>
</plugin>

The benefit over setting the system property externally as suggested here is that it automatically applies to all builds / executions.

Upvotes: 0

Stanislav
Stanislav

Reputation: 2677

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

Upvotes: 42

Jorge Ferreira
Jorge Ferreira

Reputation: 97919

You can try the -q switch.

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

Upvotes: 182

VonC
VonC

Reputation: 1328012

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.

Upvotes: 41

curious_prism
curious_prism

Reputation: 349

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

Upvotes: 3

m13r
m13r

Reputation: 2731

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

Upvotes: 6

jgrtalk
jgrtalk

Reputation: 281

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

You can add in the JVM parameters :

-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN

Beware of UPPERCASE.

Upvotes: 28

ankon
ankon

Reputation: 4235

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.

Upvotes: 2

Sietse
Sietse

Reputation: 7955

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

Upvotes: 7

Related Questions