Merge "Update mariaDB version in portal-db Dockerfile" into guilin
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
index 4c67429..b2ef2bc 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
@@ -54,6 +54,7 @@
 import org.onap.portalsdk.core.logging.format.AlarmSeverityEnum;
 import org.onap.portalsdk.core.logging.format.AuditLogFormatter;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.logging.logic.LoggerProperties;
 import org.onap.portalsdk.core.util.SystemProperties;
 import org.onap.portalsdk.core.util.SystemProperties.SecurityEventTypeEnum;
 import org.onap.portalsdk.core.web.support.UserUtils;
@@ -108,6 +109,7 @@
 	 * @return Object array
 	 */
 	public Object[] before(SecurityEventTypeEnum securityEventType, Object[] args, Object[] passOnArgs) {
+		try {
 		String className = "";
 		if (passOnArgs.length > 0 && passOnArgs[0] != null)
 			className = passOnArgs[0].toString();
@@ -117,6 +119,7 @@
 
 		// Initialize Request defaults only for controller methods.
 		MDC.put(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP, getCurrentDateTimeUTC());
+		MDC.put(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP, getCurrentDateTimeUTC());
 		MDC.put(EPCommonSystemProperties.TARGET_ENTITY, EPCommonSystemProperties.ECOMP_PORTAL_BE);
 		MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, methodName);
 		if (MDC.get(Configuration.MDC_KEY_REQUEST_ID) == null||MDC.get(Configuration.MDC_KEY_REQUEST_ID).isEmpty()){
@@ -124,31 +127,24 @@
 			MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId);
 		}
 		MDC.put(EPCommonSystemProperties.PARTNER_NAME, "Unknown");
-		MDC.put(Configuration.MDC_SERVICE_NAME, EPCommonSystemProperties.ECOMP_PORTAL_BE);
 
+		EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className);
+		MDC.put(SystemProperties.STATUS_CODE, "INPROGRESS");
+
+		// Log security message, if necessary
 		if (securityEventType != null) {
 			MDC.put(className + methodName + EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,
 					getCurrentDateTimeUTC());
+			MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,getCurrentDateTimeUTC());
+			MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, getCurrentDateTimeUTC());
+			this.calculateDateTimeDifference(MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
+			MDC.put("CustomField1", "ENTRY");
+			MDC.put("CustomField2", "InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID));
 			HttpServletRequest req = null;
 			if (args.length > 0 && args[0] != null && args[0] instanceof HttpServletRequest) {
 				req = (HttpServletRequest) args[0];
 				this.setHttpRequestBasedDefaultsIntoGlobalLoggingContext(req, securityEventType, methodName);
 			}
-		}
-
-		EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className);
-		logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#after: finished {}", methodName);
-		// add the metrics log
-		logger.info(EELFLoggerDelegate.metricsLogger,  methodName + " operation is completed.");
-
-		// Log security message, if necessary
-		if (securityEventType != null) {
-			MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,getCurrentDateTimeUTC());
-			MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, getCurrentDateTimeUTC());
-			this.calculateDateTimeDifference(MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
-			MDC.put(EPCommonSystemProperties.STATUS_CODE, "INPROGRESS");
-			MDC.put("CustomField1", "ENTRY");
-			MDC.put("CustomField2", "InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID));
 			try {
 				MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName());
 			} catch (Exception e) {
@@ -173,10 +169,21 @@
 				MDC.remove(EPCommonSystemProperties.PARTNER_NAME);
 				MDC.remove(Configuration.MDC_SERVICE_NAME);
 			}
+			logger.debug(EELFLoggerDelegate.debugLogger, "{} was invoked.", methodName);
 			
 			MDC.remove(Configuration.MDC_SERVER_FQDN);
+		} else {
+		MDC.put(SystemProperties.METRICSLOG_END_TIMESTAMP, getCurrentDateTimeUTC());
+		this.calculateDateTimeDifference(MDC.get(SystemProperties.METRICSLOG_BEGIN_TIMESTAMP),MDC.get(SystemProperties.METRICSLOG_END_TIMESTAMP));
+		MDC.put("CustomField1", "INVOKE");
+			
 		}
+		MDC.put("CustomField2", " InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID));
+		logger.info(EELFLoggerDelegate.metricsLogger, methodName + " operation is started.");
 		logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#before: entering {}", methodName);
+		} catch (Exception e) {
+			adviceLogger.error(EELFLoggerDelegate.errorLogger, "before failed", e);
+		}
 		return new Object[] { "" };
 	}
 
@@ -191,6 +198,7 @@
 	 */
 	public void after(SecurityEventTypeEnum securityEventType, String statusCode, String responseCode, Object[] args,
 			Object[] returnArgs, Object[] passOnArgs) {
+		try {
 		String className = "";
 		if (passOnArgs.length > 0 && passOnArgs[0] != null)
 			className = passOnArgs[0].toString();
@@ -216,8 +224,6 @@
 			MDC.put(EPCommonSystemProperties.PARTNER_NAME, "Unknown");
 		}
 		
-		MDC.put(Configuration.MDC_SERVICE_NAME, EPCommonSystemProperties.ECOMP_PORTAL_BE);
-
 
 		MDC.put(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP,
 				MDC.get(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP));
@@ -248,9 +254,7 @@
 		}
 
 		EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className);
-		logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#after: finished {}", methodName);
-		// add the metrics log
-		logger.info(EELFLoggerDelegate.metricsLogger,  methodName + " operation is completed.");
+		
 
 		// Log security message, if necessary
 		if (securityEventType != null) {
@@ -296,7 +300,15 @@
 			MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
 			MDC.remove(EPCommonSystemProperties.RESPONSE_CODE);
 			
-		}
+		} else{
+				MDC.put(SystemProperties.CUSTOM_FIELD1, "INVOKE-RETURN");
+			}
+
+			MDC.put(SystemProperties.STATUS_CODE, "COMPLETE");
+			MDC.put("CustomField2", " InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID));
+		logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#after: finished {}", methodName);
+		// add the metrics log
+		logger.info(EELFLoggerDelegate.metricsLogger,  methodName + " operation is completed.");
 		MDC.remove("CustomField1");
 		MDC.remove("CustomField2");
 		MDC.remove(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP);
@@ -305,6 +317,9 @@
 		MDC.remove(EPCommonSystemProperties.MDC_TIMER);
 		MDC.remove(EPCommonSystemProperties.TARGET_ENTITY);
 		MDC.remove(EPCommonSystemProperties.TARGET_SERVICE_NAME);
+		} catch (Exception e) {
+			adviceLogger.error(EELFLoggerDelegate.errorLogger, "after failed", e);
+		}
 	
 	}
 
diff --git a/ecomp-portal-BE-os/src/main/resources/logback.xml b/ecomp-portal-BE-os/src/main/resources/logback.xml
index 5cd2e28..da73aa0 100644
--- a/ecomp-portal-BE-os/src/main/resources/logback.xml
+++ b/ecomp-portal-BE-os/src/main/resources/logback.xml
@@ -44,6 +44,9 @@
 
 	<!-- specify the component name -->
 	<property name="componentName" value="onapportal"></property>
+	
+	<!--  specify the application name -->
+    <property name="application_name" value="Portal"></property>
 
 	<!-- specify the base path of the log directory -->
 	<property name="logDirPrefix" value="${catalina.base}/logs"></property>
@@ -72,7 +75,7 @@
 		value="%X{MetricsLogBeginTimestamp}|%X{MetricsLogEndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{TargetVisualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}| %msg%n" />
 	
 	<property name="errorLoggerPattern"
-		value="%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ClassName}|%X{AlertSeverity}|%X{ErrorCode}|%X{ErrorDescription}| %msg%n" />
+		value="%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDescription}| %msg%n" />
 	
 	<property name="defaultLoggerPattern"
 		value="%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%X{ClassName}| %msg%n" />
@@ -279,15 +282,15 @@
 		<appender-ref ref="asyncEELFServer" /> </logger> <logger name="com.att.eelf.policy" 
 		level="info" additivity="false"> <appender-ref ref="asyncEELFPolicy" /> </logger> -->
 
-	<logger name="com.att.eelf.audit" level="info" additivity="false">
+	<logger name="EELFAudit" level="info" additivity="false">
 		<appender-ref ref="asyncEELFAudit" />
 	</logger>
 
-	<logger name="com.att.eelf.metrics" level="info" additivity="false">
+	<logger name="EELFMetrics" level="info" additivity="false">
 		<appender-ref ref="asyncEELFMetrics" />
 	</logger>
 
-	<logger name="com.att.eelf.error" level="info" additivity="false">
+	<logger name="EELFError" level="info" additivity="false">
 		<appender-ref ref="asyncEELFError" />
 	</logger>