From 3e50db35165086df8b36f79dfd8dcf8ca940192f Mon Sep 17 00:00:00 2001 From: wasanthawso2 Date: Fri, 18 Sep 2020 10:41:49 +0530 Subject: [PATCH 1/2] ANLT-1177 - Log authentication bearer token on all error scenarios --- pom.xml | 7 +------ .../java/com/wso2telco/logging/PropertyLogHandler.java | 9 ++++++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index ce317da..9a06c76 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ logging-extension logging-extension - 1.1.1 + 1.1.1.1 bundle @@ -154,8 +154,3 @@ - - - - - diff --git a/src/main/java/com/wso2telco/logging/PropertyLogHandler.java b/src/main/java/com/wso2telco/logging/PropertyLogHandler.java index 53fa3db..31e656b 100644 --- a/src/main/java/com/wso2telco/logging/PropertyLogHandler.java +++ b/src/main/java/com/wso2telco/logging/PropertyLogHandler.java @@ -25,6 +25,7 @@ import org.apache.synapse.mediators.AbstractMediator; import org.json.XML; +import java.util.Map; import java.util.TreeMap; public class PropertyLogHandler extends AbstractMediator { @@ -116,6 +117,11 @@ private void logResponseProperties(MessageContext messageContext, org.apache.axi private void logErrorProperties(MessageContext messageContext, org.apache.axis2.context.MessageContext axis2MessageContext, boolean isPayloadLoggingEnabled) { UniqueIDGenerator.generateAndSetUniqueID("EX", axis2MessageContext); if (isPayloadLoggingEnabled) { + Map transportHeaders = (Map) axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); + String authorization = null; + if (transportHeaders != null) { + authorization = (String) transportHeaders.get("Authorization"); + } logHandler.info("TRANSACTION:errorResponse," + ",API_REQUEST_ID:" + axis2MessageContext.getProperty(REQUEST_ID) + ",REQUEST_BODY:" + messageContext.getEnvelope().getBody().toString() + @@ -128,7 +134,8 @@ private void logErrorProperties(MessageContext messageContext, org.apache.axis2. ",APPLICATION_ID:" + messageContext.getProperty(APPLICATION_ID) + ",ERROR_CODE:" + messageContext.getProperty(ERROR_CODE) + ",HTTP_STATUS:" + axis2MessageContext.getProperty(HTTP_SC) + "" + - ",ERROR_MESSAGE:" + messageContext.getProperty(ERROR_MESSAGE)); + ",ERROR_MESSAGE:" + messageContext.getProperty(ERROR_MESSAGE) + + ",AUTHORIZATION:" + authorization); } } From 36b6bb796cdab8a3514c732941fa3d381f308fa5 Mon Sep 17 00:00:00 2001 From: wasanthawso2 Date: Fri, 18 Sep 2020 11:51:00 +0530 Subject: [PATCH 2/2] ANLT-1177 Readme changes --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index da192cb..c57ca58 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,12 @@ System Requirements Enable Request ID and Payload Logging ===================================== +Make sure to remove previously installed versions of logging-extension from "/wso2telcohub/repository/components/lib" and "wso2telcohub-2.0.0/repository/components/dropins" before applying new. + Follow below three steps for enabling request ID and payload logging -1) Apply logging-extension-1.0.0-SNAPSHOT.jar to API Manager; - a) Copy and paste the 'logging-extension-1.0.0-SNAPSHOT.jar' in to deployed api manager lib directory. (Patch source is available under "/wso2telcohub/repository/components/lib".) +1) Apply logging-extension-1.1.1.1.jar to API Manager; + a) Copy and paste the 'logging-extension-1.1.1.1.jar' in to deployed api manager lib directory. (Patch source is available under "/wso2telcohub/repository/components/lib".) The actual deployment path is as follows; wso2telcohub-2.0.0/repository/components/dropins