Add RequestId and PartnerName in log 21/13021/2
authorpranavdi <Pranav.Dixit@amdocs.com>
Sun, 17 Sep 2017 06:57:07 +0000 (12:27 +0530)
committerpranavdi <Pranav.Dixit@amdocs.com>
Mon, 18 Sep 2017 08:19:24 +0000 (13:49 +0530)
The Onap application logging guidelines suggest the logs should have MDCs
for RequestId and PartnerName to create audit trail. Adding the same for
AAI logs

Change-Id: Idfc6c4c0d31eaec90c8c397ee526072a09e1504e
Issue-ID: AAI-274
Signed-off-by: pranavdi <Pranav.Dixit@amdocs.com>
aai-traversal/src/main/java/org/openecomp/aai/interceptors/AAILogJAXRSInInterceptor.java

index a0ddeff..958639f 100644 (file)
@@ -46,6 +46,7 @@ import org.openecomp.aai.util.HbaseSaltPrefixer;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
+import org.slf4j.MDC;
 
 public class AAILogJAXRSInInterceptor extends JAXRSInInterceptor {
 
@@ -216,8 +217,22 @@ public class AAILogJAXRSInInterceptor extends JAXRSInInterceptor {
                                } else if (replacedTransId) { 
                                        logMsg = "Replaced invalid requestID of " + transId + " Assigned " + newTransId;
                                }
-                       } 
-                       
+                               MDC.put("RequestId",newTransId);
+                       }
+                       else {
+                               MDC.put("RequestId",transId);
+                       }
+
+
+                       List<String> fromAppIdList = headersList.get("X-FromAppId");
+                       if (fromAppIdList != null) {
+                               String fromAppId = null;
+                               for (String fromAppIdValue : fromAppIdList) {
+                                       fromAppId = fromAppIdValue;
+                               }
+                               MDC.put("PartnerName",fromAppId);
+                       }
+
                        List<String> contentType = headersList.get("Content-Type");
                        if (contentType == null) {
                                ct = (String)message.get(Message.CONTENT_TYPE);