Skip to content

Commit 78c29bd

Browse files
authored
Merge pull request #47 from wasanthawso2/release_v1.5.0.1
ANLT-1248 LOG Access Token in request-response logger for error cases
2 parents 4ee940a + c952782 commit 78c29bd

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ Follow below three steps for enabling request ID and payload logging
5252
<class name="com.wso2telco.logging.PropertyLogHandler"/>
5353

5454
c) If the request ID and the payload of the error response from backend needs to be logged for all APIs, then add the following two entries below the sequence key="com.apigate.bizao.sequence" of _throttle_out_handler_.xml , _auth_failure_handler_.xml and fault.xml
55+
--
56+
***On fault.xml please make sure to add below entries immediately after \<filter xpath="$ctx:CUSTOM_HTTP_SC"> tag***
57+
--
5558

5659
<property name="message.type" scope="axis2" type="STRING" value="error"/>
5760
<class name="com.wso2telco.logging.PropertyLogHandler"/>

pom.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<artifactId>logging-extension</artifactId>
2525
<name>logging-extension</name>
2626

27-
<version>1.5.0</version>
27+
<version>1.5.0.1</version>
2828
<packaging>bundle</packaging>
2929
<dependencies>
3030
<dependency>
@@ -154,8 +154,3 @@
154154
</plugins>
155155
</build>
156156
</project>
157-
158-
159-
160-
161-

src/main/java/com/wso2telco/logging/PropertyLogHandler.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
******************************************************************************/
1616
package com.wso2telco.logging;
1717

18+
import java.util.Map;
19+
1820
import org.apache.axiom.om.impl.llom.OMTextImpl;
1921
import org.apache.commons.logging.Log;
2022
import org.apache.commons.logging.LogFactory;
@@ -106,6 +108,11 @@ private void logResponseProperties(MessageContext messageContext, org.apache.axi
106108

107109
private void logErrorProperties(MessageContext messageContext, org.apache.axis2.context.MessageContext axis2MessageContext, boolean isPayloadLoggingEnabled) {
108110
if (isPayloadLoggingEnabled) {
111+
Map transportHeaders = (Map) axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
112+
String authorization = null;
113+
if (transportHeaders != null) {
114+
authorization = (String) transportHeaders.get("Authorization");
115+
}
109116
logHandler.info("TRANSACTION:errorResponse" +
110117
",API_REQUEST_ID:" + messageContext.getProperty(UUID) +
111118
",REQUEST_BODY:" + messageContext.getEnvelope().getBody().toString() +
@@ -118,7 +125,8 @@ private void logErrorProperties(MessageContext messageContext, org.apache.axis2.
118125
",APPLICATION_ID:" + messageContext.getProperty(APPLICATION_ID) +
119126
",ERROR_CODE:" + messageContext.getProperty(ERROR_CODE) +
120127
",HTTP_STATUS:" + axis2MessageContext.getProperty(HTTP_SC) + "" +
121-
",ERROR_MESSAGE:" + messageContext.getProperty(ERROR_MESSAGE)
128+
",ERROR_MESSAGE:" + messageContext.getProperty(ERROR_MESSAGE) +
129+
",AUTHORIZATION:" + authorization
122130
);
123131
}
124132
}

0 commit comments

Comments
 (0)