首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >janino logback配置中的"else if“

janino logback配置中的"else if“
EN

Stack Overflow用户
提问于 2017-02-21 23:02:38
回答 2查看 4.1K关注 0票数 2

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

我的案子-

代码语言:javascript
复制
<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>
EN

回答 2

Stack Overflow用户

发布于 2017-02-22 21:08:06

您可以在多个级别中使用if-then-else

代码语言:javascript
复制
<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>
票数 1
EN

Stack Overflow用户

发布于 2017-10-30 17:33:35

试着这样做。

代码语言:javascript
复制
<if condition=''>
  <then>..</then>
  <else>
    <if condition=''>
      <then>..</then>
      <else>..</else>
    </if>
  </else>
</if>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42370870

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档