---
title: "Policy-based Logging for Azure API Management: Full Payload, Context, and Retention with Nodinite"
description: Discover how Nodinite enables policy-based logging for Azure API Management, providing full payload and context capture, flexible retention, and non-intrusive integration for actionable insights and compliance.
---

# <i class="fal fa-cloud-arrow-down" aria-hidden="true"></i> Azure API Management Service Policy-based Logging

Unlock comprehensive, policy-based logging for your Azure API Management Service APIs with <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>. This guide shows you how to capture every request and response—including payloads and headers—without intrusive code changes or data loss.

✅ Capture full payloads and headers for every API request and response  
✅ Eliminate data loss—extract and reindex new fields anytime  
✅ Apply granular retention policies by message type  
✅ Integrate non-intrusively with your existing solutions  
✅ Gain actionable insights and ensure compliance with ease  

<aside aria-label="Info" class="nodinite-note nodinite-note--info">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-square-info"></i> Info</p>
<div class="nodinite-note__content"><p>This guide teaches you how to apply a <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>-specific policy to enable logging from the Azure API Management Service platform.</p></div>
</aside>

## Why Choose Nodinite Logging Over Application Insights and Competing Solutions?

In today’s fast-paced business environments, you need more than just data collection—you need actionable insights and complete context. While tools like Application Insights and other platforms require predefined logic to capture key values, <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Logging removes the guesswork, prevents data loss, and gives you long-term flexibility.

## <i class="fal fa-rocket" aria-hidden="true"></i> Nodinite Logging vs. Application Insights & Other Competitors

### 1. Full Payload Logging—No Predefined Logic Needed

* With <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>, you avoid coding up-front logic to extract key values like correlation IDs, order numbers, or transaction details.  
* Log all message payloads and context values in full, ensuring you always have complete visibility.  
* If you forget to log a value with Application Insights or similar tools, it’s lost forever. With <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>, you can extract and index new fields at any time.  
* <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> imposes no size restriction, unlike many other options.  

*Key Advantage:* You don’t need developers to anticipate every logging requirement—log everything and extract later as needed.  

### 2. Flexible Search & Reindexing—No More Data Loss

* Competing solutions make it too late to add a new search field after logging.  
* <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> lets you create new search fields and reindex old data anytime, preserving historical context.  
* If you extract a field incorrectly, just fix the expression and reindex—no data lost.  

*Key Advantage:* You avoid data loss from changing business needs or mistakes in log field definitions.  

### 3. Non-Intrusive, Policy-Based Logging

* Unlike Application Insights, which requires custom logging code, <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> uses a policy-based, non-intrusive approach.  
* Log in parallel with your existing monitoring solutions—no application changes required.  

*Key Advantage:* Achieve low performance overhead, no intrusive code changes, and full flexibility to run alongside existing tools and policies.  

### 4. Granular, Message-Type Level Retention

* Competing solutions limit retention by fixed days or quotas, forcing you to choose between losing logs or paying more.  
* <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> lets you define retention per message type, so you keep high-value transactions longer and purge less important logs earlier.  

*Key Advantage:* Optimize retention based on business value, not arbitrary limits or storage constraints.  

## <i class="fal fa-fire" aria-hidden="true"></i> The Bottom Line: Why Nodinite Wins

✅ Log everything—no upfront coding required  
✅ Prevent data loss—reindex old data anytime  
✅ Log large payloads—no message size limits  
✅ Integrate non-intrusively—run alongside existing solutions  
✅ Control retention—keep critical logs longer without extra cost  

<aside aria-label="Tip" class="nodinite-note nodinite-note--tip">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-lightbulb"></i> Tip</p>
<div class="nodinite-note__content"><p><strong>With <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>, you never have to say "I wish we had logged that." Everything is available when you need it.</strong></p></div>
</aside>

---

This guide presents three ways to create and send the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Log Event][].  

|Policy|Full payload ([Body](#body))|HTTP Headers ([Context](#context))|<i class="fal fa-traffic-light" aria-hidden="true"></i> Monitoring|  
|---|---|---|---|  
|<i class="fal fa-boxes" aria-hidden="true"></i> 1. Any size, [Blob Storage Policy][] (**recommended**)|✅ Yes|✅ Yes|[Azure Agent][]<br/>[Non Events Agent][]|  
|<i class="fal fa-code-branch" aria-hidden="true"></i> 2. <200KB, [Event Hub Policy][]|✅ Yes|✅ Yes|[Azure Agent][]<br/>[Non Events Agent][]|  
|<i class="fal fa-link" aria-hidden="true"></i> 3. Direct API call [Log API Policy][] (supported, but not recommended)|✅ Yes|✅ Yes|[Web Services Agent][]<br/>[Non Events Agent][]|  

<div class="mermaid">
graph LR
    subgraph "Payload (Any size)"
        AA[Azure API Management</br>with Policy 1 - Blob Storage] --> | 1. Log Event | roBS[Blob Storage]  
    end
    subgraph "Payload < 200KB"
        A[Azure API Management</br>with Policy 2 Event Hub]
        A --> | 2. Log Event | B(Event Hub)  
    end
    subgraph "Consumption tier - API Call"
        AAA[Azure API Management</br>with Policy 3]
    end
    subgraph "Nodinite"
        AAA -.->|"3. Log Event (NOT our recommendation)"| F  
        B --> C{Pickup Service}
        C --> F[Log API]
        roBS --> C
    end
</div>

*Diagram: Policy-based logging and event flow for Azure API Management and Nodinite.*

When you activate the policy ([Blob Storage Policy][] or [Event Hub Policy][]), the code running in **Azure API Management** creates a <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>-specific [JSON Log Event][] and sends it to intermediate storage.

The <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Pickup Log Events Service Logging Agent][] collects the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Log Events][Log Event] from the intermediate store (Event Hub or Blob Storage Container). This pattern is [Asynchronous][Asynchronous Logging].

<aside aria-label="Tip" class="nodinite-note nodinite-note--tip">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-lightbulb"></i> Tip</p>
<div class="nodinite-note__content"><p><i class="fal fa-clock" aria-hidden="true"></i> Use the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> <a href="https://docs.nodinite.com/logging-and-monitoring/non-events/overview/">Non-Events Monitoring Agent</a> to get alerts if you have too many or too few events within a period.</p></div>
</aside>

## Body

Log the full payload. If you use the [Blob Storage Policy][], message size does not matter. If it is <200KB, use the [Event Hub Policy][]. Storing the payload in <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> lets you use [Search Fields][] in [Log Views][] to create a rich, on-demand user experience for your business.

<aside aria-label="Important" class="nodinite-note nodinite-note--important">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-message-exclamation"></i> Important</p>
<div class="nodinite-note__content"><p>When you log the payload, provide a name for the <a href="https://docs.nodinite.com/repository-model/message-types/overview/">Message Type</a>.</p></div>
</aside>

You can change the body display using [Stylesheets][]. This lets you hide content as needed. Use [Role][Roles]-based security to control who can access and view content.

## Context

A <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Log Event][] supports a **Context**—a collection of key-value pairs. Along with HTTP Headers, you can add properties in the Logging policy. Later, use these to create [Search Fields][] for self-service [Log Views][].

<table>
    <tr>
        <th>Request Headers</th>
        <th>Response Headers</th>
    </tr>
    <tr>
        <td><img src="https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/AzureAPIMgmt/RequestContext.png" alt="Example of request headers captured in Nodinite logging context"/></td>
        <td><img src="https://docs.nodinite.com/media/Documentation%20Pictures/LogAgent/AzureAPIMgmt/ResponseContext.png" alt="Example of response headers captured in Nodinite logging context"/></td>
    </tr>
</table>

*Screenshots: Example of request and response headers captured by Nodinite logging.*

<aside aria-label="Tip" class="nodinite-note nodinite-note--tip">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-lightbulb"></i> Tip</p>
<div class="nodinite-note__content"><p>You can add to your policy exactly which properties to include in the Logging.</p></div>
</aside>

If you log too much, adjust the following [System Parameter][System Parameters]:

* [ContextPropertiesFilters][]

Since you control Logging in the Policy, you determine what to include up front.

---

## Troubleshooting

Contact our [Support][] if you need help implementing [Logging][].

### Logging Options

The diagram below shows the different options for logging from Azure to <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>.

<div class="mermaid">
graph LR
    subgraph "Integration solution"
        C[Azure Function</br>with Serilog logging] --- | <1 MB payload | C1(Serilog Event Hub Sink)  
        C --> | Any size | C2(Serilog Blob Storage Sink)  
        A[Azure API Management Service API</br>with Policy] --- | <200 KB payload | A2(Policy2)  
        A --- | Any size | A1(Policy1)  
        B[Azure Logic App</br>with the proper diagnostic setting enabled]
    end
    subgraph "Event Hub"
        A2--> | 1. Nodinite JSON Log Event | AA(EH1)  
        C1--> | 1. Nodinite JSON Log Event | AA  
        C1 -.- | 1. Nodinite JSON Log Event | CC(EH2)  
        B--> | 2. Azure Diagnostics log | BB(EH3)  
    end
    subgraph "Azure Storage Account"
        A1--> | 1. Nodinite JSON Log Event | Cont(Container1)  
    end
    C2 --> | 1. Nodinite JSON Log Event | Cont  
    subgraph "Nodinite"
        Cont --> ro[Pickup Service]
        AA --> ro
        CC -.-> ro
        BB --> roLA(Logic Apps Logging and Monitoring Agent)
    end
</div>

*Diagram: Logging options from Azure to Nodinite, including API Management, Functions, and Logic Apps.*

If you log from the API **policy** to an Event Hub entity, you can reuse the Event Hub entity if the content is a <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [JSON Log Event][].

<aside aria-label="Important" class="nodinite-note nodinite-note--important">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-message-exclamation"></i> Important</p>
<div class="nodinite-note__content"><p>EH1, EH2, and EH3 must each have their own syncpoint (bookmark)—one blob storage container for each event hub entity and client.</p></div>
</aside>

* Use the [Blob Storage Policy][] if possible for less administration and large message support.  
* [Logging from Azure functions][Serilog] can share the same Event Hub as APIM if the Log Event is a <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [JSON Log Event][].  
* [Logging from Azure Logic Apps][LogicAppsAgent] requires other event hubs as targets since the content is in a different format.  

<aside aria-label="Tip" class="nodinite-note nodinite-note--tip">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-lightbulb"></i> Tip</p>
<div class="nodinite-note__content"><p>Use separate event hub entities for different purposes and needs—multiple Logic App Logging, multiple API Management Services, multiple APIs, multiple Azure functions, all according to your architecture.</p></div>
</aside>

Using a shared Event Hub for a <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [JSON Log Event][] reduces administration (configure the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Pickup Log Events Service Logging Agent][] to fetch these events).<br/>The disadvantage can be performance-related, or you may need to consider pricing, scalability, retention, and number of partitions.

<aside aria-label="Important" class="nodinite-note nodinite-note--important">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-message-exclamation"></i> Important</p>
<div class="nodinite-note__content"><p>Do not use the same Event Hub Entity for <a href="https://docs.nodinite.com/logging-and-monitoring/azure-logic-apps/overview/">Logic Apps Logging</a> as for <a href="https://docs.nodinite.com/logging-and-monitoring/serilog/overview/">Serilog</a> and Policy-based solutions. Diagnostics from Logic Apps are from Microsoft, while the others create a <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> <a href="https://docs.nodinite.com/core-services/log-event/features/json-log-event/">JSON Log Event</a>. These cannot appear on the same Event Hub Entity.</p></div>
</aside>

## <i class="fal fa-shield-check" aria-hidden="true"></i> What firewall settings are required for Azure API Management logging?

Azure API Management opens every connection **outbound**; no <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> agent runs in Azure, and there is no [Monitoring Service][] or Agent Server hop for logging. The policy decides the path: the [Blob Storage Policy][] and the [Event Hub Policy][] write to intermediate storage that the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Pickup Service][Pickup Log Events Service Logging Agent] reads, and the [Log API Policy][] posts directly to the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [Log API][]. Each arrow starts at the side that opens the connection.

<div class="mermaid">
graph LR
    subgraph "Azure API Management"
        roAPIM(fa:fa-cloud API with Nodinite policy)
    end
    subgraph "Azure Storage"
        roBlob(fa:fa-boxes *.blob.core.windows.net)
    end
    subgraph "Azure Event Hubs"
        roEH(fa:fa-code-branch *.servicebus.windows.net)
    end
    subgraph "Nodinite Core Services Server"
        roPickup(fa:fa-truck-pickup Pickup Service)
        roLogAPI(fa:fa-cloud-arrow-down Log API)
    end
    roAPIM --> |"443"| roBlob
    roAPIM --> |"5671-5672, 443"| roEH
    roAPIM -.-> |"Log API site port"| roLogAPI
    roPickup --> |"see Pickup Service"| roBlob
    roPickup --> |"see Pickup Service"| roEH
</div>

*Network diagram: APIM writes to Blob Storage or Event Hubs, and the Pickup Service collects the Log Events. The dashed direct Log API call is supported but not recommended.*

### Between Azure API Management and Azure Storage or Event Hubs

These rules matter only when you restrict APIM outbound traffic (VNet injection with a network security group or a firewall). See the Microsoft [virtual network configuration reference](https://learn.microsoft.com/en-us/azure/api-management/virtual-network-reference)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>. For Storage Accounts and Event Hubs behind their own firewall, see [Network Restrictions & Alternative Solutions][Network Restrictions].

|Direction|Source|Destination|Protocol|Port(s)|Purpose|Notes|  
|---|---|---|---|---|---|---|  
|Outbound|Azure API Management|`<account>.blob.core.windows.net`|TCP|443|HTTPS|[Blob Storage Policy][]|  
|Outbound|Azure API Management|`<namespace>.servicebus.windows.net`|TCP|5671, 5672, 443|AMQP, HTTPS|[Event Hub Policy][]; service tag `EventHub`|  

### Between Azure API Management and the Log API

Required only for the [Log API Policy][]. On Windows Server, <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> v7 hosts the [Log API][] as its own [IIS][] web site, on a port you set per environment in the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Portal ([Servers step][]).

|Direction|Source|Destination|Protocol|Port(s)|Purpose|Notes|  
|---|---|---|---|---|---|---|  
|Inbound|Azure API Management|Core Services Server|TCP (HTTPS)|Log API site port|Post Log Events|Allow the APIM outbound IP addresses, or reach the Log API through your VNet|  

### Between the Pickup Service and Azure Storage or Event Hubs

The [Pickup Service][Pickup Log Events Service Logging Agent] reads the container or Event Hub and posts to the Log API; see the [Pickup Service firewall settings][Pickup firewall].

### Between the servers and DNS

|Direction|Source|Destination|Protocol|Port(s)|Purpose|Notes|  
|---|---|---|---|---|---|---|  
|Outbound|Azure API Management|DNS Server|TCP/UDP|53|Name resolution|Only with custom DNS in a VNet; Azure DNS needs no rule|  

<aside aria-label="Important" class="nodinite-note nodinite-note--important">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-message-exclamation"></i> Important</p>
<div class="nodinite-note__content"><p><strong>Stateful Firewalls</strong>: Response traffic for established outbound connections is allowed automatically.</p></div>
</aside>

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

<i class="fal fa-truck-pickup" aria-hidden="true"></i> [Pickup Log Events Service Logging Agent][]  
<i class="fal fa-user-secret" aria-hidden="true"></i> [Azure Application Access][AzureApplicationsAccess]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

<i class="fal fa-file-code" aria-hidden="true"></i> [JSON Log Event][]  
<i class="fal fa-wrench" aria-hidden="true"></i> [Managing][Azure Agent - Managing API Logger]  
<i class="fal fa-monitor-waveform" aria-hidden="true"></i> [Monitoring][Azure Agent - Monitoring Logger]  
<i class="fal fa-clock" aria-hidden="true"></i> [Non Events Agent][]  
<i class="fal fa-file-lines" aria-hidden="true"></i> [Stylesheets][]  
<i class="fal fa-coins" aria-hidden="true"></i> [Reduce Azure API Management Logging Costs][]  

Interested in logging from other Azure Related Services?

* [Logging from Azure Logic Apps][LogicAppsAgent]  
* [Logging from Azure functions][Serilog]  

[Asynchronous Logging]:https://docs.nodinite.com/core-services/log-api/features/asynchronous-logging/
[Azure Agent]:https://docs.nodinite.com/logging-and-monitoring/azure/overview/
[Azure Agent - Managing API Logger]:https://docs.nodinite.com/logging-and-monitoring/azure/features/api-management/event-hub-logger/managing-logger/
[Azure Agent - Monitoring Logger]:https://docs.nodinite.com/logging-and-monitoring/azure/features/api-management/event-hub-logger/monitoring-logger/
[AzureApplicationsAccess]:https://docs.nodinite.com/install-and-update/troubleshooting/azure/azure-application-access/
[Blob Storage Policy]:https://docs.nodinite.com/logging-and-monitoring/azure-api-management/policy/blob-storage/
[ContextPropertiesFilters]:https://docs.nodinite.com/administration/settings/system-parameters/contextpropertiesfilters/
[Event Hub Policy]:https://docs.nodinite.com/logging-and-monitoring/azure-api-management/policy/event-hub/
[IIS]:https://docs.nodinite.com/install-and-update/troubleshooting/iis/overview/
[JSON Log Event]:https://docs.nodinite.com/core-services/log-event/features/json-log-event/
[Log API]:https://docs.nodinite.com/core-services/log-api/overview/
[Log API Policy]:https://docs.nodinite.com/logging-and-monitoring/azure-api-management/policy/log-api/
[Log Event]:https://docs.nodinite.com/core-services/log-event/overview/
[Log Views]:https://docs.nodinite.com/administration/log-management/log-views/features/what-is-a-log-view/
[Logging]:https://docs.nodinite.com/logging/
[LogicAppsAgent]:https://docs.nodinite.com/logging-and-monitoring/azure-logic-apps/overview/
[Message Types]:https://docs.nodinite.com/repository-model/message-types/overview/
[Monitoring Service]:https://docs.nodinite.com/core-services/monitoring-service/overview/
[Network Restrictions]:https://docs.nodinite.com/logging-and-monitoring/azure-api-management/policy/network-restrictions/
[Non Events Agent]:https://docs.nodinite.com/logging-and-monitoring/non-events/overview/
[Pickup firewall]:https://docs.nodinite.com/logging-and-monitoring/pickup-logevents-service/getting-started/prerequisites/#fa-shield-check-firewall-requirements
[Pickup Log Events Service Logging Agent]:https://docs.nodinite.com/logging-and-monitoring/pickup-logevents-service/overview/
[Reduce Azure API Management Logging Costs]:https://docs.nodinite.com/logging-and-monitoring/azure-api-management/troubleshooting/reduce-azure-api-management-logging-costs/
[Roles]:https://docs.nodinite.com/administration/access-management/roles/features/what-is-a-role/
[Search Fields]:https://docs.nodinite.com/administration/log-management/search-fields/features/what-is-a-search-field/
[Serilog]:https://docs.nodinite.com/logging-and-monitoring/serilog/overview/
[Servers step]:https://docs.nodinite.com/install-and-update/getting-started/version-7/install-nodinite-v7-steps/04-servers/#core-platform-services
[Stylesheets]:https://docs.nodinite.com/administration/customize/stylesheets/features/what-is-a-stylesheet/
[Support]:https://support.nodinite.com
[System Parameters]:https://docs.nodinite.com/administration/settings/system-parameters/overview/
[Web Services Agent]:https://docs.nodinite.com/logging-and-monitoring/web-services/overview/