Skip to content

Commit 090e3e7

Browse files
authored
Add our classic logback-test.xml for nicer logs (#90)
Signed-off-by: HARPER Jon <[email protected]>
1 parent 54d59a7 commit 090e3e7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<configuration>
2+
<!-- configure nicer logs for tests:
3+
4+
spring boot default format:
5+
> 2023-10-19T12:33:32.067+02:00 INFO 950066 - - - [ main] o.s.b.t.m.w.SpringBootMockServletContext : Initializing Spring TestDispatcherServlet ''
6+
7+
this conf format:
8+
> 12:49:58.755 [main] INFO org.springframework.boot.test.mock.web.SpringBootMockServletContext - Initializing Spring TestDispatcherServlet ''
9+
10+
I guess they chose a very tabular format and show dates and PID because for
11+
log files on servers it's useful, but not so for tests..
12+
13+
also the format changes midtest (before and after the springboot banner) when springboot
14+
configures the loggers so it's not coherent:
15+
16+
spring boot default:
17+
> 09:24:26.018 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration
18+
> :: Spring Boot :: (v3.1.2)
19+
> 2023-10-20T09:26:57.664+02:00 INFO 1026967 - - - [ main] o.s.b.t.m.w.SpringBootMockServletContext : Initializing Spring TestDispatcherServlet ''
20+
21+
this conf (uses the same pattern all the time as the initial one in the default springboot conf):
22+
> 09:32:28.415 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration
23+
> :: Spring Boot :: (v3.1.2)
24+
> 09:32:45.146 [main] INFO org.springframework.boot.test.mock.web.SpringBootMockServletContext - Initializing Spring TestDispatcherServlet ''
25+
26+
TODO: is there a better way to do this ? Or should sprinboot test do this themselves??
27+
-->
28+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
29+
<encoder>
30+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
31+
</pattern>
32+
</encoder>
33+
</appender>
34+
<root level="info">
35+
<appender-ref ref="STDOUT"/>
36+
</root>
37+
38+
</configuration>

0 commit comments

Comments
 (0)