Logback Spring多个配置文件



我在logback中定义了两个Spring配置文件,一个用于文件写入,另一个仅用于控制台写入。我想当spring应用程序被多个配置文件激活,如:file-logging1,file-logging2,console-logging,只有最后一个控制台日志记录工作,所以没有写文件,但只有控制台。发生的情况是file-logging1 - file-logging2工作并写入文件,但在控制台上没有写入。基本上和我期望的相反。我该如何让它像掌机日志一样发挥作用?

<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>

可以添加

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

最新更新