diff --git a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/logging/APILogHandler.java b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/logging/APILogHandler.java index 945a5fd55ba2..fb574e0f8535 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/logging/APILogHandler.java +++ b/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/logging/APILogHandler.java @@ -91,8 +91,12 @@ public static void logAPI(String flow, MessageContext messageContext) { ThreadContext.put("apiContext", selectedApi.getContext()); ThreadContext.put("apiVersion", selectedApi.getApiVersion()); if (messageContext.getProperty(API_TO) != null) { - String apiTo = "/" + messageContext.getProperty(API_TO); - ThreadContext.put("resourceName", apiTo.replaceFirst(selectedApi.getContext(), "")); + String apiTo = (String) messageContext.getProperty(API_TO); + String resourceName = apiTo.replaceFirst(selectedApi.getContext(), ""); + if(resourceName.isEmpty()){ + resourceName = "/"; + } + ThreadContext.put("resourceName", resourceName); } } ThreadContext.put("tenantDomain", (String) messageContext