Reputation: 5012
I've got a very simple spring cloud gateway application (nothing custom, directly download from start.spring.io, just select gateway and sleuth). To enable access logs, I have to set the system property reactor.netty.http.server.accessLogEnabled
:
@SpringBootApplication
class Application
fun main(args: Array<String>) {
System.setProperty(ReactorNetty.ACCESS_LOG_ENABLED, "true")
runApplication<Application>(*args)
}
And everything works just fine:
...
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
Now when I add a routing to the application:
@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")
}
}
}
}
)
}
}
The tracing information is gone:
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
It also happens with routes defined in application.xml
.
What am I missing? Do I need to do anything while configuring routes?
Upvotes: 3
Views: 2168
Reputation: 1225
They did some changes with spring boot 2.4. Check the release notes here - https://github.com/spring-cloud/spring-cloud-sleuth/wiki/Spring-Cloud-Sleuth-3.0-Migration-Guide#spring-cloud-gateway-manual-reactor-tracing-instrumentation
Upvotes: 1