如何为配置中尚不存在的任何 spring 配置文件指定默认 Logback 配置

Pav*_*dko 4 spring logback spring-logback

这是我的简化 logback-spring.xml 配置:

<configuration>

    <!-- appender config -->

    <springProfile name=dev>
        <!-- dev specific config here -->
    </springProfile>

    <springProfile name=prod>
        <!-- prod specific config here -->
    </springProfile>

    <!-- other profiles -->

</configuration>
Run Code Online (Sandbox Code Playgroud)

当我使用不同的配置文件运行我的应用程序时,我想获得一些默认的日志配置。我找不到有关在logback-spring.xml.

请注意,定义了 2 个以上的配置文件,并且我不知道其他临时配置文件的名称。

谢谢,帕夫洛

Myk*_*ura 8

你可以这样定义它:

<configuration>

<!-- appender config -->

<springProfile name=dev>
    <!-- dev specific config here -->
</springProfile>

<springProfile name=prod>
    <!-- prod specific config here -->
</springProfile>

<!-- other profiles -->

<springProfile name="!(dev| prod)">
   <!-- other specific config here -->
</springProfile>
Run Code Online (Sandbox Code Playgroud)