我設置了logback.xml
來根據活動的彈簧配置文件選擇使用哪個appender。該技術完美的作品,當我運行使用的應用程序當通過Maven運行時,Logback中沒有彈簧配置文件
java -jar -Dspring.profiles.active=local path/to/target/application.war
但不是當我運行它使用Spring Boot Maven Plugin,例如
mvn spring-boot:run -Drun.profiles=local
這裏的logback.xml
<root level="INFO">
<if condition='"${spring.profiles.active}".contains("local")'>
<then>
<appender-ref ref="CONSOLE"/>
</then>
<else>
<appender-ref ref="FILE"/>
</else>
</if>
</root>
我會注意到,在資料中正確顯示在應用程序本身的相關部分,處理logback.xml時只是不可用。
從IntelliJ IDE運行時也會出現此問題。
是否有另一種方法使用Maven Spring Boot Plugin使配置文件對於logback.xml解析器可見,並且它是否也可以用於IntelliJ?