Let's say we have a WebFlux Annotated Controller like the following:
@PostMapping(value = "api/create/user", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseStatus(value = HttpStatus.OK)
public Mono<Boolean> createUser(@Valid @RequestBody UserInfo userInfo) {
log.info("userInfo request body : {}", userInfo);
return userInfoService.createUserInfo(userInfo);
}
We assume we use an SLF4J logger implementation and we have file appenders defined. This is a blocking operation. How should it be handled? Not only on Controller level but on Service level as well since we may have needs to debug or trace various steps of a flow. Should AsyncAppender be used e.g. https://logging.apache.org/log4j/2.x/manual/async.html ?
I believe that there is not enough documentation on this topic to explain the details, the options and various use-cases.
Comment From: rstoyanchev
@kmandalas thanks for raising this.
Indeed using the Asynchronous Loggers is the best available option. There are recent efforts like the reactive-logger library that may be worth taking a look at but all in all logging APIs are pervasive and difficult to change.
Comment From: kmandalas
Thanks for the feedback. Should we label this as question and close it? Or a documentation action is needed?
Comment From: rstoyanchev
Thanks for the reminder. I'll add something to the docs.