HomeAbout Me

How to log request and response payload in Azure API Management

By Sri Gunnala
Published in Microsoft Azure
January 01, 2022
1 min read
How to log request and response payload in Azure API Management

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.

Prerequisites

  1. An Azure subscription — If you do not have an azure subscription, create a free account before you begin.
  2. A provision API Management resource — What is Azure API Management
  3. An Application Insights resource
  4. A Log analytics workspace resource — Understand What Log Analytics and how to configure it
  5. It would need a place holder (repository to hold the logs)
    1. Configure Application Insights for API Management.
    2. Configure Log Analytics workspace for API Management.

Configure APIs to log Request and Response Payload

  1. 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.

Azure API Management API Settings
Azure API Management API Settings

  1. Select destination as Application Insight resource that was configured and click on Advanced Options

Azure API Management Application Insights
Azure API Management Application Insights

  1. 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.

Azure API Management - Configure payload logging
Azure API Management - Configure payload logging

  1. 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

Azure API Management - get request payload
Azure API Management - get request payload


Tags

#Azure#AzureAPIManagement
Previous Article
Build your first Alexa skill with Alexa.NET and Azure Functions
Sri Gunnala

Sri Gunnala

Learner | Reader | Blogger | Azure Enthusiast

Topics

Front End
Microsoft Azure
Microsoft .NET

Newsletter

Sri Gunnala - Make sure to subscribe to newsletter and be the first to know the news.

Related Posts

Azure APIM Caching Policy | Cache-lookup Policy | HTTP GET | Non-Cache HTTP POST
September 21, 2024
2 min

Legal Stuff

Privacy NoticeCookie PolicyTerms Of Use

Social Media