禁用Spring Boot WebClient日志

我想构建一个简单的Spring Web客户端,它从标准输入发送消息,但WebClient在标准输出上显示全部debug informations。

如何禁用WebClient生成的日志?

客户端代码

WebClient webclient = WebClient.builder().baseUrl("http://localhost:8080/").build();
webClient.post().uri(uriBuilder -> uriBuilder.path("/test").queryParam("id",1).build()).retrieve().bodyToMono(Log.class).block();

解决方案

您可以根据需要自定义日志。作为您提到的图像,
转到应用程序。属性将记录器的值设置为OFF[io.netty]

logging.level.io.netty=off

是否要完全禁用项目中的所有日志,请禁用下面的root

logging.level.root=off

相关文章