[@Pooja Gupta](/@Pooja Gupta ](https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-app-insights#performance-implications-and-log-sampling)Thanks for reaching out to the Microsoft Q&A forum. I see that your ask is regarding handling the ClientConnectionFailure error from being logged in to the Application insights logs.
There are multiple reasons why ClientConnectionFailure could occur:
"ClientConnectionFailure" occurs when the client application that initiates the call with APIM abandons the request before completion. When this happens, APIM drops everything it was doing and logs a Client Connection Failure message. These failures generally occurs when the request is taking too long to complete so the client either gives up (a user may close the browser) or the client application may have a time out. APIM has no control on when or why the client decides to abandon the request. So technically this is not an APIM issue.
As mentioned in the below table, the ClientConnection failure is logged in the Application inights as an Exception telemetry item:
More Info here.
You can enable the Application Insights it at the API level or at the Global level as shown below:
This will only log exceptions that have a severity level of "Error" or higher, which includes exceptions with HTTP status codes matching 4xx or 5xx. At times the ClientConnection failure will have status code ZERO (0). This will not be logged then. However, If it has status code of 4XX or 5XX it will be logged.
Alternatively, To avoid the ClientConnection exception while analyzing your Application insights logs, you could filter this while querying the Exceptions telemetry using the concerned operation-id as shown below:
On a side note, please be aware of the performance implications on APIM with enabling App Insights.