Home > Mobile >  Logback Spring multiple profiles
Logback Spring multiple profiles

Time:12-03

I have two Spring profiles defined in my logback one for file writing and one only for console writing. 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. What happens is that file-logging1 file-logging2 works and write on file but there is no write on console. 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>

CodePudding user response:

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