Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logback specify the location of the default configuration file as a system property not working

export logback.configurationFile=123 on mac os x got this: "-bash: export: `logback.configurationFile=123': not a valid identifier"

Tried export logback_configurationFile=123 that worked. but logback does not seem to recognize that env variable. Any suggestions?

like image 621
Bobo Avatar asked Feb 10 '12 20:02

Bobo


1 Answers

-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}
like image 155
Peter Svensson Avatar answered Oct 16 '22 06:10

Peter Svensson