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