Capture the Request and Response logs on an API in MongoDB using Java

I want to capture the request and response of the APIs coming to the log handler in MongoDB using Java