foal
foal

Reputation: 731

Logback load configuration priorities

Official documentation describes priorities for classpath configuration (test -> groovy -> xml -> Configurator SPI) and mention the system property named logback.configurationFile to specify external configuration. But what if the product contains the logback.xml on the classpath and user specify external config with logback.configurationFile property. Which config will be loaded classpath or external?

Upvotes: 1

Views: 1356

Answers (2)

Yahor
Yahor

Reputation: 681

Here is the full list from higher to lower priority:

  1. logback.configurationFile system property (only *.xml and *.groovy are accepted)
  2. logback-test.xml from the classpath
  3. logback.groovy from the classpath
  4. logback.xml from the classpath
  5. Configurator implementation specified by META-INF/services/ch.qos.logback.classic.spi.Configurator
  6. Default BasicConfigurator (console appender)

Source: logback ContextInitializer v.1.2.6.

Upvotes: 1

foal
foal

Reputation: 731

At least for version 1.2.3 (latest stable version), the property has the highest priority. The configuration loaded in the ch.qos.logback.classic.util.ContextInitializer class in findURLOfDefaultConfigurationFile method

Upvotes: 1

Related Questions