我有一个spring应用程序,它使用logbook logger进行请求/响应日志记录
pom.xml
<dependency>
<groupId>org.zalando</groupId>
<artifactId>logbook-spring-boot-starter</artifactId>
<version>2.14.0</version>
</dependency>
application.yml
logging:
level:
org.zalando.logbook: TRACE
logback正在记录传入和传出响应,如下所示
2022-11-09T09:00:51,084Z {"origin":"remote","type":"request","correlation":"c6d7a74....}
我怎样才能使它以这种方式记录?
2022-11-09T09:00:51.036210Z - info: {"origin":"remote","type":"request","correlation":"c6d7a74...}
尝试使用logback.xml中的模式,但似乎没有任何效果
<configuration>
<appender name="STDOUT" class="org.zalando.logbook.json.JsonHttpLogFormatte">
<encoder>
<pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
1条答案
按热度按时间fv2wmkja1#
我通过添加
appender.console.layout.pattern = %d{ISO8601} - info: %msg%n
这一行来修改resources/log4j2.properties
,从而解决了此问题文件如下所示