关于Java Spring Webflux WebClient和wiretap日志记录的快速问题。
我目前正在使用SpringBoot Webflux WebClient 2.5.0进行Java编程,以进行传出HTTP请求(其中我是源)。我需要发起HTTP请求(到目标)。
我创建的传出HTTP客户端如下所示:
webClientUtil.getWebClient().mutate().baseUrl(someUrl).build().post().body(BodyInserters.fromValue(someRequest)).exchangeToMono(clientResponse -> clientResponse.bodyToMono(SomeResponse.class));
我想要记录请求和响应,因此我正在编写以下内容:
final HttpClient httpClient = HttpClient.create().wiretap("reactor.netty.http.client.HttpClient", LogLevel.INFO, AdvancedByteBufFormat.HEX_DUMP)
在一个 Util 类中:
public WebClient getWebClient() {
final HttpClient httpClient = HttpClient.create().wiretap("reactor.netty.http.client.HttpClient", LogLevel.INFO, AdvancedByteBufFormat.HEX_DUMP).metrics(true, Function.identity()).proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP).host(proxyUrl));
return WebClient.create().mutate().defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE, HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).clientConnector(new ReactorClientHttpConnector(httpClient)).build();
}
WebClient实现已经测试并且可用。
我将我的日志记录级别设置为INFO,使用logging.level.root=INFO
。
请注意,日志级别为info,wiretap也为info。
不幸的是,我没有看到任何额外的日志。
请问我做错了什么吗?
谢谢!