9 min. reading time

I think everyone of us knows these terrible log lines that blow up the Maven log output sometimes when you've cleared your local repository. Why does the artifact resolution write out the downloading procedure for every single artifact. This unneccessarily blows up log output and hides the important things.

Ok most people now may state that a deletion of the local repository is the exception and is not performed very often but this is just an example to visualize the problem. The Downloading/Downloaded messages occur every time new artifacts are loaded from the remote repositories which may be when building new projects or even when adding new dependencies or plugins to the project.

Bigger problem on CI-Servers

Althogh some downloading messages may occur from time to time on your local machine and even if you have a full-blown log output after deleting the local repository you can get over it and ignore those log outputs, the next one will be much cleaner...

But running your build on a CI-Server often requires a local repository that is private to your build in order to minimize interferences with other build jobs. In this case you will always have a full-blown build log including all downloading messages that hide the important log statements since the private repository is always empty when the build starts. This is not acceptable!

Example log output

This is the beginning of a sample log output after clearing the local repository:

09:09:15:36,357 [INFO] Scanning for projects...
Downloading: http://nexus:8081/nexus/content/groups/public/com/itemis/org-parent/3/org-parent-3.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/com/itemis/org-parent/3/org-parent-3.pom (6.0 kB at 33 kB/s)
09:15:37,023 [INFO] ------------------------------------------------------------------------
09:15:37,024 [INFO] Reactor Build Order:
09:15:37,024 [INFO]
09:15:37,024 [INFO] Unleash Parent
09:15:37,024 [INFO] Unleash SCM Provider API
09:15:37,024 [INFO] Unleash Utilities
09:15:37,024 [INFO] Unleash Maven Plugin
09:15:37,027 [INFO]
09:15:37,027 [INFO] ------------------------------------------------------------------------
09:15:37,027 [INFO] Building Unleash Parent 2.6.1-SNAPSHOT
09:15:37,027 [INFO] ------------------------------------------------------------------------
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata.xml (1.1 kB at 252 B/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/3.7.0/maven-compiler-plugin-3.7.0.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/3.7.0/maven-compiler-plugin-3.7.0.pom (11 kB at 249 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/30/maven-plugins-30.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/30/maven-plugins-30.pom (10 kB at 363 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/maven-parent/30/maven-parent-30.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/maven-parent/30/maven-parent-30.pom (41 kB at 2.2 MB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/apache/18/apache-18.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/apache/18/apache-18.pom (16 kB at 825 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/3.7.0/maven-compiler-plugin-3.7.0.jar
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-compiler-plugin/3.7.0/maven-compiler-plugin-3.7.0.jar (58 kB at 669 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-javadoc-plugin/maven-metadata.xml
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-javadoc-plugin/maven-metadata.xml (1.1 kB at 561 B/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-javadoc-plugin/3.0.0-M1/maven-javadoc-plugin-3.0.0-M1.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-javadoc-plugin/3.0.0-M1/maven-javadoc-plugin-3.0.0-M1.pom (16 kB at 300 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-javadoc-plugin/3.0.0-M1/maven-javadoc-plugin-3.0.0-M1.jar
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-javadoc-plugin/3.0.0-M1/maven-javadoc-plugin-3.0.0-M1.jar (408 kB at 4.9 MB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom (3.9 kB at 87 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom (13 kB at 502 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/maven-parent/21/maven-parent-21.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/maven-parent/21/maven-parent-21.pom (26 kB at 1.3 MB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/apache/10/apache-10.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/apache/10/apache-10.pom (15 kB at 925 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar (25 kB at 536 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom (6.4 kB at 177 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/23/maven-plugins-23.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/23/maven-plugins-23.pom (9.2 kB at 354 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/maven-parent/22/maven-parent-22.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/maven-parent/22/maven-parent-22.pom (30 kB at 1.6 MB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/apache/11/apache-11.pom
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/apache/11/apache-11.pom (15 kB at 780 kB/s)
Downloading: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.jar
Downloaded: http://nexus:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.jar (27 kB at 817 kB/s)
09:15:44,479 [INFO]
09:15:44,479 [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ unleash-parent ---
...

And this is the same portion of the log without the downloading messages:

09:18:43,094 [INFO] Scanning for projects...
09:18:43,441 [INFO] ------------------------------------------------------------------------
09:18:43,441 [INFO] Reactor Build Order:
09:18:43,441 [INFO]
09:18:43,441 [INFO] Unleash Parent
09:18:43,442 [INFO] Unleash SCM Provider API
09:18:43,442 [INFO] Unleash Utilities
09:18:43,442 [INFO] Unleash Maven Plugin
09:18:43,445 [INFO]
09:18:43,445 [INFO] ------------------------------------------------------------------------
09:18:43,445 [INFO] Building Unleash Parent 2.6.1-SNAPSHOT
09:18:43,445 [INFO] ------------------------------------------------------------------------
09:18:44,160 [INFO]
09:18:44,160 [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ unleash-parent ---
...

As you can see the log is trashed by many of the downloading messages that are totally useless. Here are some numbers: The regular log of this project is exactly 193 lines long but with the downloading log output the log of this project is blown up to a length of 1539 lines. This is about 8 times of the original log length!

Especially on CI-Servers where you have to analyze problems such logs are hard to sell to team mates. Important information are burried under a ton of useless log messages making it hard to capture the ongoings during the build.

But luckily there's a solution for that:

How to remove the downloading log messages

First of all you will notice that the Downloading/Downloaded lines are no real log output since they seem to be written directly to System.out instead of the log appender (there is no log level prepended to these lines). This point restricts the following solution to the batch mode (-B or --batch-mode) since this mode captures System.out output and writes it through the console appender.

Now the suppression of these log lines can be achieved in batch mode using the following logger configuration option setting the appropriate log level to warnings:

  • org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn

The above property can be handed over to the Maven execution as a system property which makes up the following command for our sample seen above:

mvn clean install -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn

Simple but effective ;)

Comments