Unable to log request body in the logfile even after using pre-function plugin

I want to log the request body along with other logs for my service and route. I have enabled file-log plugin through which i can gather logs for that specific service. But i do not get request body inside the log files. So i have enabled pre-function plugin for that service and route using CLI and after that i am getting some logs but they are logged in error.log file along with other logs which is not proper.
I want to log request body for all my requests for that service and route in the separate logfile which i have created and configured inside file-log plugin. Can we add / configure settings in pre-function plugin to log request body in separate logfile also.

plz help, any kind of details is appreciated.


@hardik use below pre-function plugin along with file login plugin

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
name: pre-function-plugin
plugin: pre-function
- kong.log.set_serialize_value(“request.body”, kong.request.get_raw_body())
- kong.log.set_serialize_value(“response.body”, kong.response.get_raw_body())