我已经使用 Spring RestTemplate 一段时间了,当我尝试调试它的请求和响应时,我总是遇到困难。我基本上希望看到与我在打开“详细”选项的情况下使用curl 时看到的相同内容。例如:
curl -v http://twitter.com/statuses/public_timeline.rss
将显示发送的数据和接收的数据(包括标头、cookie 等)。
我检查了一些相关帖子,例如:
如何在 Spring RestTemplate 中记录响应?
但我还没有设法解决这个问题。
一种方法是实际更改 RestTemplate 源代码并在其中添加一些额外的日志记录语句,但我发现这种方法确实是最后的手段。应该有某种方法告诉 Spring Web Client/RestTemplate 以更友好的方式记录所有内容。
我的目标是能够使用以下代码来完成此操作:
restTemplate.put("http://someurl", objectToPut, urlPathValues);
然后在日志文件或控制台中获取相同类型的调试信息(就像我使用curl 获得的那样)。
我相信这对于任何使用 Spring RestTemplate 并遇到问题的人来说都非常有用。使用curl 来调试RestTemplate 问题是行不通的(在某些情况下)。
I have been using the Spring RestTemplate for a while and I consistently hit a wall when I'am trying to debug it's requests and responses. I'm basically looking to see the same things as I see when I use curl with the "verbose" option turned on. For example :
curl -v http://twitter.com/statuses/public_timeline.rss
Would display both the sent data and the received data (including the headers, cookies, etc.).
I have checked some related posts like :
How do I log response in Spring RestTemplate?
but I haven't managed to solve this issue.
One way to do this would be to actually change the RestTemplate source code and add some extra logging statements there, but I would find this approach really a last resort thing. There should be some way to tell Spring Web Client/RestTemplate to log everything in a much friendlier way.
My goal would be to be able to do this with code like :
restTemplate.put("http://someurl", objectToPut, urlPathValues);
and then to get the same type of debug information (as I get with curl) in the log file or in the console.
I believe this would be extremely useful for anyone that uses the Spring RestTemplate and has problems. Using curl to debug your RestTemplate problems just doesn't work (in some cases).
发布评论
评论(30)
如果您使用任何
ClientHttpRequestInterceptor
,则使用BufferingClientHttpRequestFactory
配置RestTemplate
的技巧将不起作用,如果您尝试记录日志,则将不起作用通过拦截器。这是由于InterceptingHttpAccessor
(其RestTemplate
子类)的工作方式造成的。长话短说...只需使用此类代替
RestTemplate
(请注意,这使用 SLF4J 日志记录 API,根据需要进行编辑):我同意只需要做这么多工作就可以做到这一点是愚蠢的。
The trick of configuring your
RestTemplate
with aBufferingClientHttpRequestFactory
doesn't work if you are using anyClientHttpRequestInterceptor
, which you will if you are trying to log via interceptors. This is due to the way thatInterceptingHttpAccessor
(whichRestTemplate
subclasses) works.Long story short... just use this class in place of
RestTemplate
(note this uses the SLF4J logging API, edit as needed):I agree it's silly that it takes this much work just to do this.
org.apache.http.wire
提供的日志太不可读,所以我使用 logbook 记录应用程序 Servlet 和 RestTemplate 请求 &带有有效负载的响应。build.gradle
:或 Maven 依赖项:
application.properties
(或通过 YAML):RestTemplate.java
:org.apache.http.wire
gives too unreadable logs, so I use logbook to log application Servlet and RestTemplate requests & responses with payloads.build.gradle
:or Maven dependency:
application.properties
(or trough YAML):RestTemplate.java
:现在最好的解决方案,只需添加依赖项:
它包含一个 LoggingRequestInterceptor 类,您可以通过这种方式添加到 RestTemplate 中:
通过将其作为拦截器添加到 spring RestTemplate 中来集成此实用程序,方法如下:
并将 slf4j 实现添加到您的框架中,例如log4j。
或直接使用“Zg2proRestTemplate”。 @PaulSabou 的“最佳答案”看起来如此,因为使用 spring RestTemplate 时不一定会加载 httpclient 和所有 apache.http 库。
Best solution now, just add dependency :
It contains a LoggingRequestInterceptor class you can add that way to your RestTemplate:
integrate this utility by adding it as an interceptor to a spring RestTemplate, in the following manner:
and add an slf4j implementation to your framework like log4j.
or directly use "Zg2proRestTemplate". The "best answer" by @PaulSabou looks so so, since httpclient and all apache.http libs are not necessarily loaded when using a spring RestTemplate.
我也想添加我的实现。我对所有缺少的分号表示歉意,这是用 Groovy 编写的。
我需要比提供的已接受答案更可配置的东西。这是一个非常灵活的休息模板 bean,将记录 OP 正在寻找的所有内容。
自定义日志记录拦截器类:
Rest Template Bean 定义:
实现:
Wanted to add my implementation of this as well. I apologize for all the missing semi-colons, this is written in Groovy.
I needed something more configurable than the accepted answer provided. Here's a rest template bean that's very agile and will log everything like the OP is looking for.
Custom Logging Interceptor Class:
Rest Template Bean Definition:
Implementation:
我浏览了所有答案,如果您需要设置身份验证类型或连接超时,那么您可以这样做:
I went through all answers, In case you need to set authentication type or connection time out, then you can do like this :
与使用 ClientHttpInterceptor 的响应相关,我找到了一种无需缓冲工厂即可保留整个响应的方法。只需使用一些 utils 方法将响应主体输入流存储在字节数组中,该方法将从主体复制该数组,但重要的是,用 try catch 包围此方法,因为如果响应为空(这是资源访问异常的原因),它将中断,并且在 catch 中,只需创建空字节数组,然后使用该数组和原始响应中的其他参数创建 ClientHttpResponse 的匿名内部类。您可以将新的 ClientHttpResponse 对象返回到其余模板执行链,并且可以使用先前存储的主体字节数组来记录响应。这样您就可以避免在实际响应中消耗 InputStream,并且可以按原样使用 Rest Template 响应。请注意,如果您的响应太大,这可能会很危险
Related to the response using ClientHttpInterceptor, I found a way of keeping the whole response without Buffering factories. Just store the response body input stream inside byte array using some utils method that will copy that array from body, but important, surround this method with try catch because it will break if response is empty (that is the cause of Resource Access Exception) and in catch just create empty byte array, and than just create anonymous inner class of ClientHttpResponse using that array and other parameters from the original response. Than you can return that new ClientHttpResponse object to the rest template execution chain and you can log response using body byte array that is previously stored. That way you will avoid consuming InputStream in the actual response and you can use Rest Template response as it is. Note, this may be dangerous if your's response is too big
我的记录器配置使用了 xml
那么你会得到如下所示的内容:
通过 HttpMessageConverterExtractor.java:92,你需要继续调试,在我的例子中,我得到了这个:
而这个:
outputMessage.getBody() 包含消息 http(post type ) 发送
my logger config used xml
then you will get something like below:
through HttpMessageConverterExtractor.java:92,you need continue to debug,and in my case,i got this:
and this:
outputMessage.getBody() contains the message http(post type) sends
只是为了使用
ClientHttpRequestInterceptor
的完整实现来完成示例以跟踪请求和响应:然后使用
BufferingClientHttpRequestFactory
和LoggingRequestInterceptor 实例化
:RestTemplate
BufferingClientHttpRequestFactory
是必需的,因为我们希望在拦截器和初始调用代码中使用响应正文。默认实现只允许读取响应正文一次。Just to complete the example with a full implementation of
ClientHttpRequestInterceptor
to trace request and response:Then instantiate
RestTemplate
using aBufferingClientHttpRequestFactory
and theLoggingRequestInterceptor
:The
BufferingClientHttpRequestFactory
is required as we want to use the response body both in the interceptor and for the initial calling code. The default implementation allows to read the response body only once.响应来获取完整的请求/响应
在 Spring Boot 中,您可以通过在属性(或其他 12 因素方法)中设置此输出
和
,或者只是
logging.level.org.apache.http.wire=DEBUG
似乎包含所有相关信息in Spring Boot you can get the full request/response by setting this in properties (or other 12 factor method)
this outputs
and response
or just
logging.level.org.apache.http.wire=DEBUG
which seems to contain all of the relevant information使用一些代码扩展 @hstoerr 答案:
创建 LoggingRequestInterceptor 来记录请求响应
设置 RestTemplate
Extending @hstoerr answer with some code:
Create LoggingRequestInterceptor to log requests responses
Setup RestTemplate
最好的选择是将logging.level.org.springframework.web.client.RestTemplate=DEBUG添加到application.properties文件中。
其他解决方案(例如设置
log4j.logger.httpclient.wire
)并不总是有效,因为它们假设您使用log4j
和 ApacheHttpClient
,而这并不总是有效真的。但请注意,此语法仅适用于最新版本的 Spring Boot。
Your best bet is to add
logging.level.org.springframework.web.client.RestTemplate=DEBUG
to theapplication.properties
file.Other solutions like setting
log4j.logger.httpclient.wire
will not always work because they assume you uselog4j
and ApacheHttpClient
, which is not always true.Note, however, that this syntax will work only on latest versions of Spring Boot.
您可以使用 spring-rest-template-logger 来记录
RestTemplate< /code> HTTP 流量。
将依赖项添加到您的 Maven 项目:
然后按如下方式自定义
RestTemplate
:确保在
application.properties
中启用调试日志记录:现在所有 RestTemplate HTTP 流量都将记录到 < code>org.hobsoft.spring.resttemplatelogger.LoggingCustomizer 在调试级别。
免责声明:我写了这个库。
You can use spring-rest-template-logger to log
RestTemplate
HTTP traffic.Add a dependency to your Maven project:
Then customize your
RestTemplate
as follows:Ensure that debug logging is enabled in
application.properties
:Now all RestTemplate HTTP traffic will be logged to
org.hobsoft.spring.resttemplatelogger.LoggingCustomizer
at debug level.DISCLAIMER: I wrote this library.
xenoterracide 给出的使用解决方案
很好,但问题是默认情况下不使用 Apache HttpComponents。
要使用 Apache HttpComponents,请添加到 pom.xml
并配置
RestTemplate
与:The solution given by xenoterracide to use
is good but the problem is that by default Apache HttpComponents is not used.
To use Apache HttpComponents add to your pom.xml
and configure
RestTemplate
with :这些答案都不能真正解决 100% 的问题。 mjj1409 获取了大部分信息,但方便地避免了记录响应的问题,这需要更多的工作。 Paul Sabou 提供了一个看似现实的解决方案,但没有提供足够的细节来实际实施(而且它对我来说根本不起作用)。 Sofiene 获得了日志记录,但遇到了一个关键问题:响应不再可读,因为输入流已被消耗!
我建议使用 BufferingClientHttpResponseWrapper 来包装响应对象,以允许多次读取响应正文:
这不会消耗 InputStream,因为响应正文已加载到内存中并且可以多次读取。如果您的类路径上没有 BufferingClientHttpResponseWrapper,您可以在此处找到简单的实现:
https://github.com/spring-projects/spring-android/blob/master/spring-android-rest-template/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java
对于环境上 RestTemplate:
None of these answers actually solve 100% of the problem. mjj1409 gets most of it, but conveniently avoids the issue of logging the response, which takes a bit more work. Paul Sabou provides a solution that seems realistic, but doesn't provide enough details to actually implement (and it didn't work at all for me). Sofiene got the logging but with a critical problem: the response is no longer readable because the input stream has already been consumed!
I recommend using a BufferingClientHttpResponseWrapper to wrap the response object to allow reading the response body multiple times:
This will not consume the InputStream because the response body is loaded into memory and can be read multiple times. If you do not have the BufferingClientHttpResponseWrapper on your classpath, you can find the simple implementation here:
https://github.com/spring-projects/spring-android/blob/master/spring-android-rest-template/src/main/java/org/springframework/http/client/BufferingClientHttpResponseWrapper.java
For setting up the RestTemplate:
记录 RestTemplate
选项 1. 打开调试日志记录。
配置 RestTemplate
默认情况下 RestTemplate 依赖标准 JDK 工具来建立 HTTP 连接。您可以切换到使用不同的 HTTP 库,例如 Apache HttpComponents
@豆子
公共 RestTemplate restTemplate(RestTemplateBuilder 构建器){
RestTemplaterestTemplate = builder.build();
返回休息模板;
默认情况
日志记录
application.yml
记录:
等级:
org.springframework.web.client.RestTemplate:调试
选项2.使用拦截器
包装响应
实现拦截器
配置RestTemplate
配置日志
检查LoggingRestTemplate的包,例如
application.yml
:记录:
等级:
com.example.logging: DEBUG
选项 3. 使用 httpcomponent
导入 httpcomponent 依赖
配置 RestTemplate 配置
日志记录
检查 LoggingRestTemplate 的包,例如
application.yml
中:记录:
等级:
org.apache.http: DEBUG
Logging RestTemplate
Option 1. Open debug logging.
Configurate RestTemplate
By default the RestTemplate relies on standard JDK facilities to establish HTTP connections. You can switch to use a different HTTP library such as Apache HttpComponents
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
RestTemplate restTemplate = builder.build();
return restTemplate;
}
Configurate logging
application.yml
logging:
level:
org.springframework.web.client.RestTemplate: DEBUG
Option 2. Using Interceptor
Wrapper Response
Implement Interceptor
Configurate RestTemplate
Configurate logging
Check the package of LoggingRestTemplate, for example in
application.yml
:logging:
level:
com.example.logging: DEBUG
Option 3. Using httpcomponent
Import httpcomponent dependency
Configurate RestTemplate
Configurate logging
Check the package of LoggingRestTemplate, for example in
application.yml
:logging:
level:
org.apache.http: DEBUG
我终于找到了一种以正确的方式做到这一点的方法。
大部分解决方案来自
如何配置 Spring 和SLF4J,以便我可以获取日志记录?
似乎有两件事需要完成:
第二个问题主要发生在使用 slf4j 的 spring 环境中(就像我的情况一样)。
因此,当使用 slf4j 时,请确保发生以下两件事:
类路径中没有公共日志库:这可以通过在 pom 中添加排除描述符来完成:
log4j.properties 文件存储在 spring 可以找到的类路径中的某个位置/看到它。如果您遇到问题,最后的解决方案是将 log4j.properties 文件放入默认包中(这不是一个好的做法,但只是为了看看事情是否按您的预期工作)
I finally found a way to do this in the right way.
Most of the solution comes from
How do I configure Spring and SLF4J so that I can get logging?
It seems there are two things that need to be done :
log4j.logger.httpclient.wire=DEBUG
The second issue happens mostly to spring environments where slf4j is used (as it was my case).
As such, when slf4j is used make sure that the following two things happen :
There is no commons-logging library in your classpath : this can be done by adding the exclusion descriptors in your pom :
The log4j.properties file is stored somewhere in the classpath where spring can find/see it. If you have problems with this, a last resort solution would be to put the log4j.properties file in the default package (not a good practice but just to see that things work as you expect)
---- 2019 年 7 月 ----
(使用 Spring Boot)
我很惊讶 Spring Boot 及其零配置魔法,并没有提供一种简单的方法来检查或记录简单的 JSON使用 RestTemplate 的响应主体。我查看了此处提供的各种答案和评论,并分享了我自己的(仍然)有效的蒸馏版本,并且在我看来,考虑到当前的选项(我正在使用 Spring Boot 2.1.6 和 Gradle 4.4),这似乎是一个合理的解决方案)
1. 使用 Fiddler 作为 http 代理
这实际上是一个相当优雅的解决方案,因为它绕过了创建自己的拦截器或将底层 http 客户端更改为 apache 的所有繁琐工作(见下文)。
然后
2. 使用 Apache HttpClient
将 Apache HttpClient 添加到您的 Maven 或 Gradle 依赖项。
使用 HttpComponentsClientHttpRequestFactory 作为 RestTemplate 的 RequestFactory。最简单的方法是:
在您的
application.properties
文件中启用 DEBUG(如果您正在使用 Spring Boot)如果您使用 Spring Boot,则需要确保设置了日志框架,例如使用 spring-boot-starter包含 spring-boot-starter-logging 的依赖项。
3. 使用拦截器
我将让您阅读其他答案和评论中的提案、反提案和陷阱,并自行决定是否要走这条路。
4. 记录不带正文的 URL 和响应状态
虽然这不满足记录正文的规定要求,但它是开始记录 REST 调用的快速而简单的方法。它显示完整的 URL 和响应状态。
只需将以下行添加到您的 application.properties 文件中(假设您使用的是 Spring Boot,并且假设您使用的是包含 spring-boot-starter-logging 的 spring boot starter 依赖项) /代码>)
输出将如下所示:
---- July 2019 ----
(using Spring Boot)
I was surprised that Spring Boot, with all it's Zero Configuration magic, doesn't provide an easy way to inspect or log a simple JSON response body with RestTemplate. I looked through the various answers and comments provided here, and am sharing my own distilled version of what (still) works and seems to me like a reasonable solution, given the current options (I'm using Spring Boot 2.1.6 with Gradle 4.4)
1. Using Fiddler as http proxy
This is actually quite an elegant solution, as it bypasses all the cumbersome efforts of creating your own interceptor or changing the underlying http client to apache (see below).
and then
2. Using Apache HttpClient
Add Apache HttpClient to your Maven or Gradle dependencies.
Use
HttpComponentsClientHttpRequestFactory
as RequestFactory for RestTemplate. The simplest way to do that would be:Enable DEBUG in your
application.properties
file (if you're using Spring Boot)If you're using Spring Boot, you'll need to make sure you have a logging framework set up, e.g. by using a spring-boot-starter dependency that includes
spring-boot-starter-logging
.3. Use an Interceptor
I'll let you read through the proposals, counter-proposals, and gotchas in the other answers and comments and decide for yourself if you want to go down that path.
4. Log URL and Response Status without Body
Although this doesn't meet the stated requirements of logging the body, it's a quick and simple way to start logging your REST calls. It displays the full URL and response status.
Simply add the following line to your
application.properties
file (assuming you're using Spring Boot, and assuming you are using a spring boot starter dependency that includesspring-boot-starter-logging
)The output will look something like this:
正如其他响应中所述,响应正文需要特殊处理,以便可以重复读取(默认情况下,其内容在第一次读取时被消耗)。
在设置请求时,拦截器本身可以包装响应并确保内容被保留并可以重复读取(也可以由记录器读取),而不是使用 BufferingClientHttpRequestFactory由响应的使用者):
我的拦截器,它
代码:
配置:
日志输出示例:
As stated in the other responses, the response body needs special treatment so it can be read repeatedly (by default, its contents get consumed on the first read).
Instead of using the
BufferingClientHttpRequestFactory
when setting up the request, the interceptor itself can wrap the response and make sure the content is retained and can be repeatedly read (by the logger as well as by the consumer of the response):My interceptor, which
Code:
Configuration:
Example log output:
application.properties
application.yml
application.properties
application.yml
除了另一个答案中描述的 HttpClient 日志记录之外,您还可以引入一个 ClientHttpRequestInterceptor 来读取请求和响应的正文并记录它。如果其他东西也使用 HttpClient,或者如果您想要自定义日志记录格式,您可能需要执行此操作。注意:您需要为 RestTemplate 提供 BufferingClientHttpRequestFactory,以便可以读取响应两次。
Besides the HttpClient logging described in the other answer, you can also introduce a ClientHttpRequestInterceptor that reads the body of the request and the response and logs it. You might want to do this if other stuff also uses the HttpClient, or if you want a custom logging format. Caution: you will want to give the RestTemplate a BufferingClientHttpRequestFactory such that you can read the response twice.
这可能不是正确的方法,但我认为这是打印请求和响应而不在日志中填写太多内容的最简单方法。
通过添加以下 2 行 application.properties 记录所有请求和响应,第一行用于记录请求,第二行用于记录响应。
This might not be the correct way to do it, but I think this is the most simple approach to print requests and responses without filling too much in logs.
By adding below 2 lines application.properties logs all requests and responses 1st line in order to log the requests and 2nd line to log the responses.
假设
RestTemplate
是 配置以使用 HttpClient 4.x,您可以阅读 HttpClient 的日志记录文档 这里。记录器与其他答案中指定的记录器不同。HttpClient 3.x 的日志记录配置位于此处。
Assuming
RestTemplate
is configured to use HttpClient 4.x, you can read up on HttpClient's logging documentation here. The loggers are different than those specified in the other answers.The logging configuration for HttpClient 3.x is available here.
这里的许多响应都需要更改代码和自定义类,但这确实没有必要。 Gte 一个调试代理,例如 fiddler,并设置您的 java 环境以在命令行上使用代理(-Dhttp.proxyHost 和 -Dhttp.proxyPort),然后运行 fiddler,您可以看到完整的请求和响应。它还具有许多辅助优势,例如能够在提交修改服务器之前和之后对结果和响应进行修改以运行实验。
最后一个可能出现的问题是,如果您必须使用 HTTPS,则需要从 fiddler 导出 SSL 证书并将其导入 java 密钥库 (cacerts) 提示:默认的 java 密钥库密码通常是“changeit”。
So many responses here require coding changes and customized classes and it really is not necessary. Gte a debugging proxy such as fiddler and set your java environment to use the proxy on the command line (-Dhttp.proxyHost and -Dhttp.proxyPort) then run fiddler and you can see the requests and responses in their entirety. Also comes with many ancillary advantages such as the ability to tinker with the results and responses before and after they are sent to run experiments before committing to modification of the server.
Last bit of an issue that can come up is if you must use HTTPS, you will need to export the SSL cert from fiddler and import it into the java keystore (cacerts) hint: default java keystore password is usually "changeit".
要在 Apache HttpClient 的帮助下记录到 Logback:
您需要在类路径中使用 Apache HttpClient:
将您的
RestTemplate
配置为使用 HttpClient:要记录请求和响应,请添加到 Logback 配置文件:
或者记录更多:
For logging to Logback with help from Apache HttpClient:
You need Apache HttpClient in classpath:
Configure your
RestTemplate
to use HttpClient:To log requests and responses, add to Logback configuration file:
Or to log even more:
从
spring boot 3
开始,apache 依赖项更新为:httpclient5
使用您必须使用以下属性:<代码>org.apache.hc.client5.http:DEBUG。
From
spring boot 3
, the apache dependency is more recent and it is:<artifactId>httpclient5</artifactId>
which is usedYou must then use the following property:
org.apache.hc.client5.http:DEBUG
.添加到上面的讨论中,这仅代表快乐的场景。如果出现错误,您可能无法记录响应。
在这种情况下加上上面的所有情况,您必须重写 DefaultResponseErrorHandler 并将其设置如下
Adding to above discussion this only represents Happy scenarios. probably you will not be able to log the response if an Error comes .
In this case plus all the cases above you must override DefaultResponseErrorHandler and set it like below
奇怪的是,这些解决方案都不起作用,因为 RestTemplate 似乎没有返回某些客户端和服务器 500x 错误的响应。在这种情况下,您还可以通过实现 ResponseErrorHandler 来记录这些内容,如下所示。这是代码草案,但您明白了:
您可以设置与错误处理程序相同的拦截器:
并且拦截器实现了这两个接口:
Strangely, none of these solutions work as RestTemplate does not seem to return the response on some client and server 500x errors. In which case, you will have log those as well by implementing ResponseErrorHandler as follows. Here is a draft code, but you get the point:
You can set the same interceptor as the error handler:
And the intercept implements both interfaces:
正如@MilacH 指出的,实现中存在错误。如果 statusCode >返回 400 并抛出 IOException,因为拦截器未调用 errorHandler。该异常可以被忽略,然后在处理程序方法中再次捕获。
As @MilacH pointed out, there is an error in the implementation. If an statusCode > 400 is returned a IOException is thrown, as the errorHandler is not invoked, from interceptors. The exception can be ignored and is then caught again in the handler method.
解决问题的简单方法:
resources/application.properties
文件:logging.level.org.springframework.web.client.RestTemplate=DEBUG
希望问题能得到解决!
An easy way to solve the problem:
resources/application.properties
file:logging.level.org.springframework.web.client.RestTemplate=DEBUG
Hope the problem will be resolved!
当使用 RestTemplate 并且存在2.7.5
4xx
或5xx
响应类型(如ClientHttpResponse
的正文)时,上述大多数解决方案都无法正常工作空的。这是我用来在 RestTemplate 中记录整个 HTTP 请求/响应的解决方案,而在所有情况下都不会丢失响应正文信息。 Spring boot 版本为1.创建
LoggingInterceptor
类}
2.将其附加到
RestTemplate
bean3.在应用程序中应用适当的级别
Most of the above solution doesn't work properly when RestTemplate is used and there is a
4xx
or5xx
response type asClientHttpResponse
's body is empty. Here is the solution that I used to log the whole HTTP request/response in RestTemplate without losing the response body information in all cases. The Spring boot version is<version>2.7.5</version>
1.Create
LoggingInterceptor
class}
2.Attach it to the
RestTemplate
bean3.Apply the appropriate level in the application