'How to display correlationId, request payload and response body when certain api was in wso2 apim log
I am trying to write custom api log handler for wso2 apim (4.0.0) so that it should add correlationId, request payload and response body when certain api is called. I followed the answer to similar question. So far I have done following:
public boolean handleRequestOutFlow(..) {
...
String uuIdHeader = (String) messageContext.getProperty("CORRELATION_ID_HEADER");
if (tenantDomain == null) {
tenantDomain = org.wso2.carbon.utils.multitenancy.MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
}
...
}
But uuIdHeader keeps returning null.
Any hint is appreciated on how to get correlationId, request payload and response body.
Solution 1:[1]
The correlation ID is generated when Observability logs are enabled in the API Manager server.
Therefore, to get the correlation-id printed in your logs, you have to enable the observability logs as instructed in here. You can get more insights about the observability logs and correlation IDs in the official Docs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Athiththan |
