Skip to content

Commit

Permalink
Merge pull request #45 from wasanthawso2/hotfix-1.1.1.1
Browse files Browse the repository at this point in the history
ANLT-1177 - Log authentication bearer token on all error scenarios
  • Loading branch information
wasanthawso2 authored Sep 20, 2020
2 parents fd125e3 + 36b6bb7 commit 8977b9c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ System Requirements
Enable Request ID and Payload Logging
=====================================

<b>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.</b>

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
Expand Down
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<artifactId>logging-extension</artifactId>
<name>logging-extension</name>

<version>1.1.1</version>
<version>1.1.1.1</version>
<packaging>bundle</packaging>
<dependencies>
<dependency>
Expand Down Expand Up @@ -154,8 +154,3 @@
</plugins>
</build>
</project>





9 changes: 8 additions & 1 deletion src/main/java/com/wso2telco/logging/PropertyLogHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() +
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 8977b9c

Please sign in to comment.