简体   繁体   English

Logback Spring 多个配置文件

[英]Logback Spring multiple profiles

I have two Spring profiles defined in my logback one for file writing and one only for console writing.我在我的 logback 中定义了两个 Spring 配置文件,一个用于文件写入,一个仅用于控制台写入。 I would like when the spring app is activated with multiple profiles like: file-logging1,file-logging2,console-logging that only the last one console-logging works so there is no write on file but only console.我希望当使用多个配置文件激活 spring 应用程序时,例如: file-logging1,file-logging2,console-logging只有最后一个控制台日志记录有效,因此没有写入文件,只有控制台。 What happens is that file-logging1 file-logging2 works and write on file but there is no write on console.发生的情况是 file-logging1 file-logging2 工作并写入文件但控制台上没有写入。 Basically the opposite of what I expect.基本上与我的预期相反。 How can I make it works like kind of console-logging taking over?我怎样才能让它像控制台日志一样工作? Below my settings:在我的设置下面:

<springProfile name="file-logging,file-logging1">
<logger name="com.xxx.xxx" additivity="false" level="DEBUG">
    <appender-ref ref="HTTP-DEBUG"/>
</logger>
<springProfile name="console-logging">
<logger name="org.springframework" level="DEBUG" additivity="false">
    <appender-ref ref="CONSOLE"/>
</logger>
<root level="DEBUG">
    <appender-ref ref="CONSOLE"/>
</root>

You can add你可以加

<springProfile name="(file-logging | file-logging1) & !console-logging">
<logger name="com.xxx.xxx" additivity="false" level="DEBUG">
    <appender-ref ref="HTTP-DEBUG"/>
</logger>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM