X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Flogging%2Faop%2FEPEELFLoggerAdvice.java;h=4c67429bfad9d7dff4b3e3de67ea9fff869cf257;hb=54c5ed82662ef681375675e58abc8058e3203466;hp=71338a84c66fff63c0c4f1e7026bd2623cbd2eb1;hpb=ce34d843f7e16ecddc839ee9976b4652bfdde571;p=portal.git 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 71338a84..4c67429b 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 @@ -137,6 +137,45 @@ public class EPEELFLoggerAdvice { } 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) { + adviceLogger.error(EELFLoggerDelegate.errorLogger, + " while setting the IP address ", e); + } + this.logSecurityMessage(logger, securityEventType, methodName); + + // Outgoing & LDAP messages are part of Incoming requests so, + // keep "RequestId", "PartnerName", "ServiceName", "LoginId" & + // "ResponseCode" etc. in memory and remove it only when + // finished processing the parent incoming message. + if (securityEventType != SecurityEventTypeEnum.OUTGOING_REST_MESSAGE + && securityEventType != SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) { + MDC.remove(Configuration.MDC_KEY_REQUEST_ID); + MDC.remove(EPCommonSystemProperties.PARTNER_NAME); + MDC.remove(Configuration.MDC_SERVICE_NAME); + MDC.remove(EPCommonSystemProperties.MDC_LOGIN_ID); + MDC.remove(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE); + }else{ + MDC.remove(Configuration.MDC_KEY_REQUEST_ID); + MDC.remove(EPCommonSystemProperties.PARTNER_NAME); + MDC.remove(Configuration.MDC_SERVICE_NAME); + } + + MDC.remove(Configuration.MDC_SERVER_FQDN); + } logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#before: entering {}", methodName); return new Object[] { "" }; } @@ -220,7 +259,14 @@ public class EPEELFLoggerAdvice { MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, getCurrentDateTimeUTC()); this.calculateDateTimeDifference(MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP), MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP)); - + MDC.put("CustomField1", "EXIT"); + MDC.put("CustomField2", "InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID)); + try { + MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName()); + } catch (Exception e) { + adviceLogger.error(EELFLoggerDelegate.errorLogger, + " while setting the IP address ", e); + } this.logSecurityMessage(logger, securityEventType, methodName); // Outgoing & LDAP messages are part of Incoming requests so, @@ -241,6 +287,7 @@ public class EPEELFLoggerAdvice { } // clear when finishes audit logging + MDC.remove(Configuration.MDC_SERVER_FQDN); MDC.remove(EPCommonSystemProperties.FULL_URL); MDC.remove(EPCommonSystemProperties.PROTOCOL); MDC.remove(EPCommonSystemProperties.STATUS_CODE); @@ -248,7 +295,10 @@ public class EPEELFLoggerAdvice { MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP); MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP); MDC.remove(EPCommonSystemProperties.RESPONSE_CODE); + } + MDC.remove("CustomField1"); + MDC.remove("CustomField2"); MDC.remove(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP); MDC.remove(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP); MDC.remove(EPCommonSystemProperties.METRICSLOG_END_TIMESTAMP);