【问题标题】:Disable Spring Boot Webclient logs禁用 Spring Boot Webclient 日志
【发布时间】:2021-04-05 10:12:44
【问题描述】:

我想构建一个简单的 Spring Web Client,它从 stdin 发送消息,但 WebClient 在 stdout 上显示所有 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();

【问题讨论】:

    标签: java spring spring-boot spring-webflux spring-webclient


    【解决方案1】:

    您可以根据需要自定义日志。正如你提到的图片,
    转到 application.properties 将记录器值禁用为OFF [io.netty]

    logging.level.io.netty=off
    

    您要完全禁用项目中的所有日志吗,请在下方禁用 root。

    logging.level.root=off
    

    【讨论】:

    • 不幸的是,它对我不起作用。也许是因为我直接在 main 中使用 webclient 而不使用 springbootaplication?我将编辑我的帖子以显示客户端代码。
    • 请试试这个logging.level.reactor.netty.http.client=OFF
    • 好的,它可以工作,但前提是我使用 @SpringBootApplication 和 SpringApplication.run(testClient.class, args);你认为没有那个还有其他选择吗?感谢您的帮助
    • 我对spring web客户端不太熟悉,兄弟。无论如何,请参考这个stackoverflow.com/questions/46154994/…
    猜你喜欢
    • 1970-01-01
    • 2019-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-24
    • 1970-01-01
    • 2018-03-15
    • 2019-06-03
    相关资源
    最近更新 更多