Webflux: No logs when request is filtered
MatthiasDrews opened this issue · 1 comments
MatthiasDrews commented
Webflux: No logs when request is filtered out by a WebFilter
Description
In a spring cloud gateway application it is possible (and maybe common) to have a set of global WebFilters which are applied to all requests. It turns out, that having a WebFilter which prevents further request processing (e.g. by returning a 401), prevents logging of the whole request/response by Logbook.
Expected Behavior
All requests/responses should be logged, even if further request processing is cancelled by a WebFilter.
Actual Behavior
Currently there are no logs for affected requests/responses.
Possible Fix
Steps to Reproduce
Add a filter to your application, e.g.:
@Bean
public WebFilter securityFilter() {
return ((exchange, chain) -> {
if (exchange.getRequest().getPath().value().equals("/secured")) {
exchange.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED);
return exchange.getResponse().setComplete();
} else {
return chain.filter(exchange);
}
});
}
Context
Your Environment
- SpringBoot 3.1.2
- Logbook 3.2.0
kasmarian commented
The fix will be part of 3.3.0