Logging requests and responses of an API are very crucial for debugging and troubleshooting the issues. Without this troubleshooting will take longer than usual. In this blog we will see how to log request and response payload in Azure API Management — APIM.
Go to Azure API Management Instance —> APIs —> Select APIs —> Go to settings. Under the diagnostics setting you can find Application Insights and Azure Monitor. Select Application Insights and check Enable.
Select destination as Application Insight resource that was configured and click on Advanced Options
Check Frontend Request, Frontend Response, Backend Request and Backend response. For each of these, provide Header to log as X-Forwarded-For and size give max 8192 and click save.
Now you are all set, run your APIs then go to Application Insight resource —> Logs —> requests table —> You can find the request body under customDimensions