【问题标题】:"else if" in janino logback configurationjanino logback 配置中的“else if”
【发布时间】:2017-07-11 06:50:45
【问题描述】:

我正在尝试在 logback 配置中使用 janino 条件语句,它与“if”和“else”一起工作正常。但是我想问一下是否可以在里面写“else if”?

我的情况 -

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

【问题讨论】:

    标签: conditional-statements logback janino


    【解决方案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>
    

    【讨论】:

      【解决方案2】:

      尝试这样做。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-09-07
        • 1970-01-01
        • 2019-05-23
        • 2018-05-18
        • 2020-05-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多