How to log request and response body details into log file

Is it possible to log request and response body into Kong log files? The “file-log” plugin can log request/response headers into log file But not the body.

Are there any out of the box plugins available for this? We are on version 2.7 and tried to use " kong.service.response.get_raw_body()" and “kong.service.response.get_body()” methods to capture response body as part of a custom plugin But seems like not working.

you can log the body with: return ngx.req.get_body_data()
But it is not recommended for production or with high traffic. Just for tests…

Hi Lukas,

Thanks for sharing the method. Is there a way to log the response body?