Search code examples
javalogginglogbackconfiguration-files

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?


Solution

  • 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