[logback-user] alternate configuration files on the classpath

Steve Cohen scohen at javactivity.org
Fri Oct 26 21:48:50 CEST 2012


In the logback manual,
http://logback.qos.ch/manual/configuration.html#configFileProperty,
there is the following section


> Specifying the location of the default configuration file as a system property
>
> If you wish, you can specify the location of the default configuration file with a system property named logback.configurationFile. The value of this property can be a URL, a resource on the class path or a path to a file external to the application.
>
> java -Dlogback.configurationFile=/path/to/config.xml chapters.configuration.MyApp1

There is no example of using this property to refer to a configuration 
file on the classpath, for example, an alternate configuration file 
deployed in an application jar file.  This is my requirement.  I have 
two executables, the main one, and an auto-installer for it, code for 
which lives in the same jar file, with each executable launched by its 
own batch file.

I tried placing an alternate config file on the root of the classpath 
inside the jar file (at the same directory as logback.xml).  this does 
not seem to work.

What is the correct format for defining -Dlogback.configurationFile= for 
a resource located in a jar file on the classpath or, for that matter, 
any other classpath resource more generically?


More information about the Logback-user mailing list