Skip to content

Instantly share code, notes, and snippets.

@stdmitry
Last active April 23, 2022 17:28
Show Gist options
  • Save stdmitry/314cc42d6bd40900f691a8cf77a842af to your computer and use it in GitHub Desktop.
Save stdmitry/314cc42d6bd40900f691a8cf77a842af to your computer and use it in GitHub Desktop.
Java logging example 2
@RestController
public class Example2Controller {
private static final Logger log = LoggerFactory.getLogger(Example2Controller.class);
@GetMapping("/example2")
public Mono<String> example2() {
return doSomeStuff();
}
private Mono<String> doSomeStuff() {
return
Mono.just("Some data")
.doOnEach(signal -> {
if (signal.isOnNext()) {
var requestId = (String) signal.getContextView().get("requestId");
log.info("This is request id: {}", requestId);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment