I configured logback.xmlto choose which appender to use based on the active Spring profile. This technology works great when I run the application using
java -jar -Dspring.profiles.active=local path/to/target/application.war
but not when I run it using Spring Boot Maven Plugin , for example.
mvn spring-boot:run -Drun.profiles=local
Here is the corresponding logback.xml section
<root level="INFO">
<if condition='"${spring.profiles.active}".contains("local")'>
<then>
<appender-ref ref="CONSOLE"/>
</then>
<else>
<appender-ref ref="FILE"/>
</else>
</if>
</root>
I note that the profile is really correctly displayed in the application itself, it is simply not available when processing logback.xml.
The problem also manifests itself when working with the IntelliJ IDE.
Is there another way to use the Maven Spring Boot Plugin to make the profile visible to the logback.xml parser, and will it work for IntelliJ too?