2017-02-21 57 views
1

我正在嘗試在logback配置中使用janino條件語句,並且它可以正常使用「if」和「else」。但是我想問一下是否有可能在其中寫入「else if」?「else if」in janino logback configuration

我的情況 -

<if condition='p("log.environment").equals("prod")'> 
    <then> 
     <include file="${LOG_CONFIG_DIR}/logback-prod.xml" /> 
    </then> 
</if> 

<if condition='p("log.environment").equals("uat")'> 
    <then> 
     <include file="${LOG_CONFIG_DIR}/logback-uat.xml" /> 
    </then> 
</if> 

<if condition='p("log.environment").equals("dev")'> 
    <then> 
     <include file="${LOG_CONFIG_DIR}/logback-dev.xml" /> 
    </then> 
</if> 

回答

1

可以在多級使用if-then-else

<if condition='p("log.environment").equals("prod")'> 
    <then> 
     <include file="${LOG_CONFIG_DIR}/logback-prod.xml" /> 
    </then> 
    <if condition='p("log.environment").equals("uat")'> 
     <then> 
      <include file="${LOG_CONFIG_DIR}/logback-uat.xml" /> 
     </then> 
     <else> 
      <include file="${LOG_CONFIG_DIR}/logback-dev.xml" /> 
     </else> 
    </if> 
</if> 
0

嘗試做這樣的。

<if condition=''> 
    <then>..</then> 
    <else> 
    <if condition=''> 
     <then>..</then> 
     <else>..</else> 
    </if> 
    </else> 
</if>