gpt4 book ai didi

Spring Sleuth 跟踪 ID 在 Spring Cloud Gateway 中消失了

转载 作者:行者123 更新时间:2023-12-05 05:50:39 25 4
gpt4 key购买 nike

我有一个非常简单的 spring cloud gateway 应用程序(没有自定义,直接从 start.spring.io 下载,只需选择 gateway 和 sleuth)。要启用访问日志,我必须设置系统属性 reactor.netty.http.server.accessLogEnabled:

@SpringBootApplication
class Application

fun main(args: Array<String>) {
System.setProperty(ReactorNetty.ACCESS_LOG_ENABLED, "true")
runApplication<Application>(*args)
}

一切正常:

...
2021-12-27 17:19:05.245 INFO [gateway,,] 62156 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port 8080
2021-12-27 17:19:05.284 INFO [gateway,,] 62156 --- [ main] com.example.demo.ApplicationKt : Started ApplicationKt in 1.855 seconds (JVM running for 2.262)
2021-12-27 17:19:09.914 INFO [gateway,e075b59a8a4bca5d,e075b59a8a4bca5d] 62156 --- [ctor-http-nio-2] reactor.netty.http.server.AccessLog : 127.0.0.1 - - [27/Dec/2021:17:19:09 +0100] "GET /get HTTP/1.1" 404 132 111

现在,当我向应用程序添加路由时:

@SpringBootApplication
class Application

fun main(args: Array<String>) {
System.setProperty(ReactorNetty.ACCESS_LOG_ENABLED, "true")
runApplication<Application>(*args) {
addInitializers(
beans {
bean {
ref<RouteLocatorBuilder>().routes {
route {
path("/*")
uri("https://httpbin.org")
}
}
}
}
)
}
}

追踪信息不见了:

2021-12-27 17:23:48.010  INFO [gateway,,] 62423 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 8080
2021-12-27 17:23:48.042 INFO [gateway,,] 62423 --- [ main] com.example.demo.ApplicationKt : Started ApplicationKt in 1.774 seconds (JVM running for 2.145)
2021-12-27 17:24:21.864 INFO [gateway,,] 62423 --- [ctor-http-nio-2] reactor.netty.http.server.AccessLog : 127.0.0.1 - - [27/Dec/2021:17:24:20 +0100] "GET /get HTTP/1.1" 200 613 949

它也发生在 application.xml 中定义的路由。
我错过了什么?配置路由时需要做些什么吗?

最佳答案

关于Spring Sleuth 跟踪 ID 在 Spring Cloud Gateway 中消失了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70497993/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com