Please use attached logback-spring.xml.txt sample logback-spring.xml to reproduce the issue. This issue is when we use 'highlight' conversion rule, same is the case with the custom conversion rule as well.
[spring-boot version 2.5.2]
Comment From: wilkinsona
Thanks for the report, but this does not have anything to do with Spring Boot.
The same output is produced with the following:
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>gh-27729</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.4</version>
</dependency>
</dependencies>
</project>
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%highlight(%date{DEFAULT} | [%-15thread] | %-5level | [%X{project_id}] | %-60class - %msg) %replace(%xThrowable){'\n',' '}%nopex%n</pattern>
</encoder>
</appender>
<logger name="org.springframework" level="OFF" additivity="false"/>
<root level="WARN">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
Main class:
package com.example.demo;
import org.slf4j.LoggerFactory;
public class Gh27729Application {
public static void main(String[] args) {
LoggerFactory.getLogger(Gh27729Application.class).info("Test");
}
}