【问题标题】:How to remove WARN message using Spring Cloud Sleuth and Spring Cloud Gateway如何使用 Spring Cloud Sleuth 和 Spring Cloud Gateway 删除 WARN 消息
【发布时间】:2022-05-24 18:35:34
【问题描述】:

我需要在 Netty 日志中记录跟踪,所以我添加了这个配置:

@Configuration
public class SleuthGWConfiguration {

    @Bean
    public HttpClientCustomizer customizer(HttpTracing httpTracing) {
        return (c) -> {
            return ReactorNettyHttpTracing.create(httpTracing).decorateHttpClient(c);


        };
    }
}

并且日志包含预期的跟踪:

[2m2022-05-18 18:16:16.306[0;39m [32mDEBUG [,,][0;39m [35m19820[0;39m [2m---[0;39m [2m[ctor-http-nio-2][0;39m [36mreactor.netty.http.server.HttpServer    [0;39m [2m:[0;39m [08685324-1, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:59765] Handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter@130d2eee
[2m2022-05-18 18:16:16.910[0;39m [32mDEBUG [,efbd8bcbe33f76e3,efbd8bcbe33f76e3][0;39m [35m19820[0;39m [2m---[0;39m [2m[ctor-http-nio-2][0;39m [36mr.netty.http.client.HttpClientConnect   [0;39m [2m:[0;39m [1a19d87a-1, L:/127.0.0.1:59767 - R:localhost/127.0.0.1:8085] Handler is being applied: {uri=http://localhost:8085/get, method=GET}
[2m2022-05-18 18:16:16.936[0;39m [32mDEBUG [,efbd8bcbe33f76e3,761f2b4fd9a180ba][0;39m [35m19820[0;39m [2m---[0;39m [2m[ctor-http-nio-2][0;39m [36mr.n.http.client.HttpClientOperations    [0;39m [2m:[0;39m [1a19d87a-1, L:/127.0.0.1:59767 - R:localhost/127.0.0.1:8085] Received response (auto-read:false) : [Server=gunicorn/19.9.0, Date=Wed, 18 May 2022 16:16:16 GMT, Connection=keep-alive, Content-Type=application/json, Access-Control-Allow-Origin=*, Access-Control-Allow-Credentials=true, content-length=1382]
[2m2022-05-18 18:16:16.944[0;39m [32mDEBUG [,efbd8bcbe33f76e3,efbd8bcbe33f76e3][0;39m [35m19820[0;39m [2m---[0;39m [2m[ctor-http-nio-2][0;39m [36mr.n.http.client.HttpClientOperations    [0;39m [2m:[0;39m [1a19d87a-1, L:/127.0.0.1:59767 - R:localhost/127.0.0.1:8085] Received last HTTP packet
[2m2022-05-18 18:16:16.966[0;39m [32mDEBUG [,efbd8bcbe33f76e3,efbd8bcbe33f76e3][0;39m [35m19820[0;39m [2m---[0;39m [2m[ctor-http-nio-2][0;39m [36mr.n.http.server.HttpServerOperations    [0;39m [2m:[0;39m [08685324-1, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:59765] Last HTTP response frame

但是带有警告消息一大堆应用程序启动时出现跟踪 (complete stack trace is here):

[36mo.s.c.s.a.i.w.SkipPatternConfiguration  [0;39m [2m:[0;39m Most likely, there is an actuator endpoint that indirectly references an instrumented HTTP client. An exception was thrown during bean initialization. Will ignore that exception

经过调查,我找到了the related issue。似乎这不会导致真正的问题,但我想知道是否可以创建一个配置来防止在启动时引发异常。

示例项目是available here

【问题讨论】:

    标签: spring-cloud-sleuth


    【解决方案1】:

    只需设置属性logging.level.org.springframework.cloud.sleuth.autoconfig.instrument.web.SkipPatternConfiguration=ERROR。你可以这样做,例如通过application.yml

    更新:

    对于这个问题https://github.com/spring-cloud/spring-cloud-sleuth/issues/2166,我们通过降低日志严重性来降低噪音

    【讨论】:

    • 我的问题是关于如何防止异常抛出,而不是隐藏警告消息。如果可以忽略消息,为什么日志级别设置为 WARN?它应该处于调试级别。
    • 对不起 - 我误读了你想要达到的目标。抛出异常是因为 bean 创建有些混乱。这似乎是一个错误 - 您可以在 Spring Cloud Sleuth 中提交它并参考这个 SO 问题吗?
    • 我已经更新了答案 - 我们可以将其标记为已解决吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-18
    • 2020-10-19
    • 1970-01-01
    • 2021-09-06
    • 2021-10-18
    • 2020-05-28
    相关资源
    最近更新 更多