2

I don't understand some behavior when I run:

mvn -V clean -Dorg.slf4j.simpleLogger.showThreadName=true

I get:

Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12- 14T18:29:23+01:00)
Java version: 1.8.0_31, vendor: Oracle Corporation
...
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------

So, it looks like property org.slf4j.simpleLogger.showThreadName is not recognized by slf4j

When I change this property in conf/logging/simplelogger.properties I get:

Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T18:29:23+01:00)
Java version: 1.8.0_31, vendor: Oracle Corporation
...
[main] [INFO] Scanning for projects...
[main] [INFO] ------------------------------------------------------------------------ 

Now I have what I expected.

Also mvn help:system -Dorg.slf4j.simpleLogger.showThreadName=true says that property is set.

What I do wrong?

I would like to use cli for setting properties for sl4j. I wouldn't like to change maven internal configuration file.

Slawomir Jaranowski
  • 7,381
  • 3
  • 25
  • 33
  • 1
    try setting this in `MAVEN_OPTS`, `export MAVEN_OPTS="-Dorg.slf4j.simpleLogger.showThreadName=true"` – jmj Mar 03 '15 at 22:38

1 Answers1

7

The -D option to mvn sets the argument as a maven property. org.slf4j.simpleLogger.showThreadName is a Java system property. Maven properties include Java system properties, but not vice versa.

The easiest way to pass a java system property to a library used by maven (e.g. slf4j) is to add it to the MAVEN_OPTS environment variable.

Community
  • 1
  • 1
soru
  • 5,464
  • 26
  • 30