We had a similar problem in our project where we deployed two spring boot wars in one ibm liberty web container. We fixed it by providing a custom logback-spring.xml. Following are the configurations that fixed it:
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<springProperty scope="context" name="springAppName" source="spring.application.name"/>
<property name="LOG_LEVEL_PATTERN" value="%clr(%5p) %clr([${springAppName},%X{X-B3-TraceId:-},%X{X-B3-SpanId:-},%X{X-Span-Export:-}]){yellow}" />
<!-- You can override this to have a custom pattern -->
<property name="CONSOLE_LOG_PATTERN"
value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
<file>${server.output.dir}logs/myapplication1.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${server.output.dir}logs/myapplication1%d{yyyy-MM-dd}.log</fileNamePattern>
<!--<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">-->
<!--<maxFileSize>1MB</maxFileSize>-->
<!--</timeBasedFileNamingAndTriggeringPolicy>-->
</rollingPolicy>
</appender>
<logger name="com.sample.controllers.MyController" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</logger>
<logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</logger>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
Make sure it is included in classpath by maven
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/application.properties</include>
<include>**/*.xml</include>
<include>**/*.yml</include>
</includes>
</resource>
</resources>
</build>
</profile>
</profiles>
And add the following entry in your src/main/resources/bootstrap.yml
spring:
application:
name: myapplication1
jmx:
default-domain: myapplication1
Have this configuration in each of the two spring boot applications with different application names