Logging is one of the efficient ways for debugging problems. The information about the API request such as headers, form params, query params, dynamic variables, etc. can all be logged for later reference. The information can be logged locally on the Message Processors (Apigee Edge for Private Cloud only) or to third party servers such as Sumo Logic, Splunk, or Loggly.
In the code below, the
Sumo Logic server. This means that the process of logging actually takes place during
request/response processing. This approach is counterproductive because it adds to the processing
time, thereby increasing overall latencies.
<!-- /antipatterns/examples/1-5.xml --> var sumoLogicURL = "..."; httpClient.send(sumoLogicURL); waitForComplete();
The culprit here is the call to
waitForComplete(), which suspends the caller's
operations until the logging process is complete. A valid pattern is to make this asynchronous
by eliminating this call.
- Concurrent requests can stress the resources on the Message Processor and consequently adversely affecting the processing of other requests.
- Use the MessageLogging policy to transfer/log data to Log servers or third party log management services such as Sumo Logic, Splunk, Loggly, etc.
- The biggest advantage of the Message Logging policy is that it can be defined in the Post Client Flow, which gets executed after the response is sent back to the requesting client app.
- Having this policy defined in Post Client flow helps separate the logging activity and the request/response processing thereby avoiding latencies.
Client flow option mentioned above), then it needs to be done asynchronously. In other words,
if you are using a