我设置了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?