-Dlogback.configurationFile
is not the same as setting it as an Environment variable.
The -D flag is a Java parameter to your program (accessible by System.getProperty()
) while the environment variable defined by export
will be accessible by System.getenv()
.
Looking at the Logback code it looks like it uses System.getProperty()
to read the logback.configurationFile
value.
So in reality you have to pass the parameter to the JVM on startup, this means that you can set the environment variable to whatever you like and then just use it in when you start the JVM.
export LOGBACK_CONFIG_FILE_LOCATION=/tmp/logback.conf
java -Dlogback.configurationFile=${LOGBACK_CONFIG_FILE_LOCATION}