Maven 3.1.x logging

Maven 2.x and 3.0.x use Plexus logging API with basic Maven implementation writing to stdout.

We have reached the decision that SLF4J is the best option for a logging API: SLF4J has reached a certain level of ubiquity and while SLF4J may not be perfect, it's the de facto standard and it's pointless to try and remake another one. There are many implementations to choose from, including Logback and Log4j2. All the hard work has been done. All the bridges and funnels for other systems function well, which allows others to use whatever logging implementation they like in their components, while still being able to have integrated logging.

The standard Maven distribution, from Maven 3.1.0 onward, uses the SLF4J API for logging combined with the SLF4J Simple implementation. Future versions may use a more advanced implementation, but we chose to start simple.

Looking at the distribution you will see the following layout where the simplelogger.properties, slf4j-api-x.y.z-jar and slf4j-simple-x.y.z.jar specifically relate to the SLF4J implementation:

apache-maven-3.x.y
├── LICENSE.txt
├── NOTICE.txt
├── README.txt
├── bin
│   └── ...
├── boot
│   └── ...
├── conf
│   ├── logging
│   │   └── simplelogger.properties
│   └── settings.xml
└── lib
    ├── ...
    ├── slf4j-api-x.y.z.jar
    ├── slf4j-simple-x.y.z.jar
    └── ...

Configuring logging

To configure logging with the SLF4J Simple, you can edit the properties in the ${maven.home}/conf/logging/simplelogger.properties file. Please see the linked reference documentation for details.

Every entry in this file can be overriden via commandline arguments by passing it with the -D flag. E.g. -Dorg.slf4j.simpleLogger.showThreadName=true will add the thread name to every logging line.

The default configuration for Maven is listed here.

Changing the SLF4J implementation

If you want use a different logging implementation it is simply a matter of removing the slf4j-simple JAR from the lib directory and replacing it with one of the alternative implementations, like Log4j2 or Logback.

See SLF4J documentation for more details on swapping “SLF4J bindings”.