"else if" 在 Janino 登录配置中



我试图在记录配置中使用Janino条件语句,并且与" if"one_answers" else"一起工作正常。但是我想问一下是否可以在其中写"否则"?

我的案子 -

<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>

尝试这样做。

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

您可以在Multi-Level

中使用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>

最新更新