How to specify a logback configuration as a classpath resource rather than a file
logback
Solution
You can simply put a `my-logback.xml` in the root of one of your classpath entries and specify `-Dlogback.configurationFile=my-logback.xml`. Internally it will probably use `ClassLoader#getResource(String name)` to get the file - check the JavaDoc of this method for more information.
Problem
I have the following situation. I need to be able to run two programs launched by different batch files where each batch file invokes a java class with main() from the same jar. I would like each program to have its own log. However, the second program is an installer for the first, and therefore, I don't want to/can't easily specify -Dlogback.configurationFile=/path/to/config file as that location may not yet exist. Logback documentation seems to provide a solution but I need an example of how to make it work: 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 Can anyone point me to an example where logback.configurationFile is defined as a resource on the classpath as opposed to the file system?