java - Variable Substitution in logback groovy -


i working logback.xml , variable load in string :

<filenamepattern>${logdirectory}/${logfilename}.%d{yyyy-mm-dd}.%i.html</filenamepattern> 

where logdirectory , logfilename set in .bat file before calling jar.

set logfilename=foobar 

but now, deal groovy. it's awesome , ridiculously more readable xml. variable no longer expand.

appender("file", rollingfileappender) { file = "${logdirectory}/${logfilename}.html"     rollingpolicy(timebasedrollingpolicy) {         filenamepattern = "${logdirectory}/${logfilename}.%d{yyyy-mm-dd}.%i.html"         ...     } ... }  

the path null/null :'(

worst : following test throw exception :

if ("${logconsole}" == "true") { 

anyone see how make work ?

-- edit add full logback.groovy

/*  * configuration use following variables :  * logdirectory => log folder  * logfilename => log file name  * logconsole => true console activation.  **/  import ch.qos.logback.classic.encoder.patternlayoutencoder import ch.qos.logback.classic.html.htmllayout import ch.qos.logback.core.consoleappender import ch.qos.logback.core.encoder.layoutwrappingencoder import ch.qos.logback.core.rolling.rollingfileappender import ch.qos.logback.core.rolling.sizeandtimebasedfnatp import ch.qos.logback.core.rolling.timebasedrollingpolicy  import static ch.qos.logback.classic.level.info import static ch.qos.logback.classic.level.off  def log_directory = system.getproperty("logdirectory") def log_file_name = system.getproperty("logfilename") def log_console = system.getproperty("logconsole")  appender("file", rollingfileappender) {     file = "${log_directory}/${log_file_name}.html"     rollingpolicy(timebasedrollingpolicy) {         filenamepattern = "${log_directory}/${log_file_name}.%d{yyyy-mm-dd}.%i.html"         timebasedfilenamingandtriggeringpolicy(sizeandtimebasedfnatp) {             maxfilesize = "100mb"         }         maxhistory = 5     }     encoder(layoutwrappingencoder) {         layout(htmllayout) {             pattern = "%level%date%logger{36}%msg"         }     } } appender("stdout", consoleappender) {     withjansi = true     encoder(patternlayoutencoder) {         pattern = "%d{hh:mm:ss.sss} [%thread] %highlight(%-5level) %cyan(%logger{36}) - %msg%n"     } } logger("org", info) logger("net", info) logger("freemarker", info)  // don't care bean creation @ least it's more warn logger("org.springframework.beans.factory", warn)  root(off, ["file"])  if (log_console == "true") {     root(off, ["file","stdout"]); } 

the system.getproperty() call retrieves properties set -d on java command line whereas in .bat file setting shell/environment variables.

try using system.getenv() in logback.groovy file.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -