Uredi

Deli z drugimi prek


Diagnostics logs settings reference: API Management

APPLIES TO: All API Management tiers

This reference describes settings for API diagnostics logging from an API Management instance. To enable logging of API requests, see the following guidance:

Note

Certain settings, where noted, apply only to logging to Application Insights.

Setting Type Description
Enable boolean Specifies whether logging of this API is enabled.

Logging can be enabled for all APIs or for an individual API. Settings for an individual API override settings for all APIs, if enabled.
Destination Azure Application Insights logger Specifies logger to be used for Application Insights logging.
Sampling (%) decimal Values from 0 to 100 (percent).
Specifies the percentage of requests that are logged. 0% sampling means zero requests logged, while 100% sampling means all requests logged. Default: 100

For performance impacts of Application Insights logging, see Performance implications and log sampling.
Always log errors boolean If this setting is enabled, all failures are logged, regardless of the Sampling setting.
Log client IP address boolean If this setting is enabled, the client IP address for API requests is logged.
Verbosity Specifies the verbosity of the logs and whether custom traces that are configured in trace policies are logged.

* Error - failed requests, and custom traces of severity error
* Information - failed and successful requests, and custom traces of severity error and information
* Verbose - failed and successful requests, and custom traces of severity error, information, and verbose

Default: Information
Correlation protocol Specifies the protocol used to correlate telemetry sent by multiple components to Application Insights. Default: Legacy

For information, see Telemetry correlation in Application Insights.
Headers to log list Specifies the headers that are logged for requests and responses. Default: no headers are logged.
Number of payload (body) bytes to log integer Specifies the number of initial bytes of the frontend or backend request or response body that are logged. Maximum: 8,192. Default: 0
Frontend Request Specifies whether and how frontend requests (requests incoming to the API Management gateway) are logged.

If this setting is enabled, specify Headers to log, Number of payload bytes to log, or both.
Frontend Response Specifies whether and how frontend responses (responses outgoing from the API Management gateway) are logged.

If this setting is enabled, specify Headers to log, Number of payload bytes to log, or both.
Backend Request Specifies whether and how backend requests (requests outgoing from the API Management gateway) are logged.

If this setting is enabled, specify Headers to log, Number of payload bytes to log, or both.
Backend Response Specifies whether and how backend responses (responses incoming to the API Management gateway) are logged.

If this setting is enabled, specify Headers to log, Number of payload bytes to log, or both.

Important

If enabled, logged request or response payloads can be up to 8,192 bytes. API Management also enforces a 32 KB limit for a diagnostic log entry sent to Azure Monitor, which includes the payloads and other attributes such as status codes, headers, and timestamps. If the combined size of the attributes exceeds 32 KB, API Management trims the entry by removing all body and trace content.

Next steps

  • For more information, see the reference for the Diagnostic entity in the API Management REST API.
  • Use the trace policy to add custom traces to Application Insights telemetry, resource logs, or request tracing.