conditional-statements - janino logback 配置中的 "else if"

标签 conditional-statements logback janino

我正在尝试在 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>

最佳答案

你可以在多级中使用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>

关于conditional-statements - janino logback 配置中的 "else if",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42370870/

相关文章:

haskell - Haskell 中的 "parse error on input"if-then-else 条件

java - 使用java代码将多行异常转为单行

java - "Invalid signature file digest"通过Maven添加Janino包出错

R:根据现有数据帧上的多个条件添加数据列和行

batch-file - 在CMD中使用if条件

r - 根据条件从r中的多个列中删除重复的行

slf4j - logback 文件的包含取决于内容的顺序

java - 有没有办法从每个日志级别的两个单独的 logback.xml 文件配置 logback?

java - 未找到实际参数 "int"的适用构造函数/方法,但匹配候选确实存在

java - 如何在运行时从字符串表示创建 Java 对象