Skip to content

Commit 6b4bb4d

Browse files
committed
Unify console and file logback patterns
Update the file log pattern to write the thread name after the `---` separator. The allows both file and console logs to be parsed in the same way. Fixes spring-projectsgh-2136
1 parent df1dede commit 6b4bb4d

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ The following items are output:
734734
* Log Level -- `ERROR`, `WARN`, `INFO`, `DEBUG` or `TRACE`.
735735
* Process ID.
736736
* A `---` separator to distinguish the start of actual log messages.
737+
* Thread name -- Enclosed in square brackets (may be truncated for console output).
737738
* Logger name -- This is usually the source class name (often abbreviated).
738739
* The log message.
739740

spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class DefaultLogbackConfiguration {
4646
+ "%clr(:){faint} %m%n%wex";
4747

4848
private static final String FILE_LOG_PATTERN = "%d{yyyy-MM-dd HH:mm:ss.SSS} %5p "
49-
+ "${PID:- } [%t] --- %-40.40logger{39} : %m%n%wex";
49+
+ "${PID:- } --- [%t] %-40.40logger{39} : %m%n%wex";
5050

5151
private static final Charset UTF8 = Charset.forName("UTF-8");
5252

spring-boot/src/main/resources/org/springframework/boot/logging/logback/defaults.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ initialization performed by Boot
1010
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
1111

1212
<property name="CONSOLE_LOG_PATTERN" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t{14}]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex"/>
13-
<property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } [%t] --- %-40.40logger{39} : %m%n%wex"/>
13+
<property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } --- [%t] %-40.40logger{39} : %m%n%wex"/>
1414

1515
<appender name="DEBUG_LEVEL_REMAPPER" class="org.springframework.boot.logging.logback.LevelRemappingAppender">
1616
<destinationLogger>org.springframework.boot</destinationLogger>

0 commit comments

Comments
 (0)