diff options
-rw-r--r-- | ecomp-sdk/epsdk-aaf/pom.xml | 4 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-analytics/pom.xml | 2 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-app-common/pom.xml | 2 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-app-os/pom.xml | 2 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/pom.xml | 2 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-core/pom.xml | 2 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/AppConfig.java | 3 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegateTest.java | 2 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-domain/pom.xml | 4 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-fw/pom.xml | 2 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-logger/pom.xml | 4 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java | 280 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-music/pom.xml | 4 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-workflow/pom.xml | 2 | ||||
-rw-r--r-- | ecomp-sdk/pom.xml | 2 |
15 files changed, 147 insertions, 170 deletions
diff --git a/ecomp-sdk/epsdk-aaf/pom.xml b/ecomp-sdk/epsdk-aaf/pom.xml index 4423c337..1cf2dadf 100644 --- a/ecomp-sdk/epsdk-aaf/pom.xml +++ b/ecomp-sdk/epsdk-aaf/pom.xml @@ -7,12 +7,12 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-aaf</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> <packaging>jar</packaging> <name>ONAP Portal SDK AAF Authorization</name> diff --git a/ecomp-sdk/epsdk-analytics/pom.xml b/ecomp-sdk/epsdk-analytics/pom.xml index 7789fbf0..10466b9f 100644 --- a/ecomp-sdk/epsdk-analytics/pom.xml +++ b/ecomp-sdk/epsdk-analytics/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-app-common/pom.xml b/ecomp-sdk/epsdk-app-common/pom.xml index 2af46dc8..a2a79721 100644 --- a/ecomp-sdk/epsdk-app-common/pom.xml +++ b/ecomp-sdk/epsdk-app-common/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-app-os/pom.xml b/ecomp-sdk/epsdk-app-os/pom.xml index 7e07b3d6..738ff571 100644 --- a/ecomp-sdk/epsdk-app-os/pom.xml +++ b/ecomp-sdk/epsdk-app-os/pom.xml @@ -9,7 +9,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-app-overlay/pom.xml b/ecomp-sdk/epsdk-app-overlay/pom.xml index 3e5a9879..c89c72ac 100644 --- a/ecomp-sdk/epsdk-app-overlay/pom.xml +++ b/ecomp-sdk/epsdk-app-overlay/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-core/pom.xml b/ecomp-sdk/epsdk-core/pom.xml index d44de8dc..e2842943 100644 --- a/ecomp-sdk/epsdk-core/pom.xml +++ b/ecomp-sdk/epsdk-core/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/AppConfig.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/AppConfig.java index acd39d77..b1a0b0b8 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/AppConfig.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/conf/AppConfig.java @@ -112,7 +112,8 @@ public class AppConfig extends WebMvcConfigurerAdapter implements Configurable, * each log file type that logging has been started. */ private void initGlobalLocalContext() { - logger.init(); + String appName = SystemProperties.getProperty(SystemProperties.APPLICATION_NAME); + logger.init(appName); } /** diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegateTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegateTest.java index b190c477..322e3c6b 100644 --- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegateTest.java +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegateTest.java @@ -241,7 +241,7 @@ public class EELFLoggerDelegateTest { @Test public void initTest(){ EELFLoggerDelegate eelFLoggerDelegate = new EELFLoggerDelegate(getClass().getName()); - eelFLoggerDelegate.init(); + eelFLoggerDelegate.init(SystemProperties.getProperty(SystemProperties.APPLICATION_NAME)); Assert.assertTrue(true); } diff --git a/ecomp-sdk/epsdk-domain/pom.xml b/ecomp-sdk/epsdk-domain/pom.xml index 913087b3..95061d1c 100644 --- a/ecomp-sdk/epsdk-domain/pom.xml +++ b/ecomp-sdk/epsdk-domain/pom.xml @@ -5,12 +5,12 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-domain</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> <packaging>jar</packaging> <name>ONAP Portal SDK Domain</name> diff --git a/ecomp-sdk/epsdk-fw/pom.xml b/ecomp-sdk/epsdk-fw/pom.xml index be64ae22..a52c793e 100644 --- a/ecomp-sdk/epsdk-fw/pom.xml +++ b/ecomp-sdk/epsdk-fw/pom.xml @@ -6,7 +6,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/epsdk-logger/pom.xml b/ecomp-sdk/epsdk-logger/pom.xml index 1007e8ad..e5a3a373 100644 --- a/ecomp-sdk/epsdk-logger/pom.xml +++ b/ecomp-sdk/epsdk-logger/pom.xml @@ -4,12 +4,12 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-logger</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> <name>ONAP Portal SDK Logger</name> diff --git a/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java b/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java index 901c6737..2bb1b526 100644 --- a/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java +++ b/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java @@ -1,39 +1,39 @@ /* - * ============LICENSE_START========================================== - * ONAP Portal SDK - * =================================================================== - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * +* ============LICENSE_START========================================== +* ONAP Portal SDK +* =================================================================== +* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. +* =================================================================== +* +* Unless otherwise specified, all software contained herein is licensed +* under the Apache License, Version 2.0 (the "License"); +* you may not use this software except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Unless otherwise specified, all documentation contained herein is licensed +* under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +* you may not use this documentation except in compliance with the License. +* You may obtain a copy of the License at +* +* https://creativecommons.org/licenses/by/4.0/ +* +* Unless required by applicable law or agreed to in writing, documentation +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* ============LICENSE_END============================================ +* +* */ package org.onap.portalsdk.core.logging.logic; @@ -49,6 +49,8 @@ import java.net.InetAddress; import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -71,7 +73,6 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { public static final EELFLogger applicationLogger = EELFManager.getInstance().getApplicationLogger(); public static final EELFLogger debugLogger = EELFManager.getInstance().getDebugLogger(); private static final SimpleDateFormat ecompLogDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); - private String className; private static ConcurrentMap<String, EELFLoggerDelegate> classMap = new ConcurrentHashMap<String, EELFLoggerDelegate>(); @@ -97,8 +98,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * Gets a logger for the specified class name. If the logger does not already * exist in the map, this creates a new logger. * - * @param className - * If null or empty, uses EELFLoggerDelegate as the class name. + * @param className If null or empty, uses EELFLoggerDelegate as the class name. * @return Instance of EELFLoggerDelegate */ public static EELFLoggerDelegate getLogger(final String className) { @@ -112,6 +112,28 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { return delegate; } + public static void logWrite(EELFLogger logger, Level level, String msg, Throwable th, Object... arguments) { + + if ( logger == errorLogger) { + MDC.put("ErrorCategory", ErrorSeverityEnum.ERROR.name()); + MDC.put("ErrorCode", "900"); + MDC.put("ErrorDescription", "Exception"); + } + + if (logger.isErrorEnabled()) { + logger.log(level, msg, null, arguments); + } else { + logger.log(level, msg, th, arguments); + } + + if ( logger == errorLogger) { + MDC.remove("ErrorCode"); + MDC.remove("ErrorDescription"); + MDC.remove("ErrorCategory"); + } + + } + /** * Logs a message at the lowest level: trace. * @@ -119,11 +141,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param msg */ public void trace(EELFLogger logger, String msg) { - if (logger.isTraceEnabled()) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.trace(msg); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); - } + logWrite(logger, Level.TRACE, msg, null); } /** @@ -134,11 +152,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param arguments */ public void trace(EELFLogger logger, String msg, Object... arguments) { - if (logger.isTraceEnabled()) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.trace(msg, arguments); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); - } + logWrite(logger, Level.TRACE, msg, null, arguments); } /** @@ -149,11 +163,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param th */ public void trace(EELFLogger logger, String msg, Throwable th) { - if (logger.isTraceEnabled()) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.trace(msg, th); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); - } + logWrite(logger, Level.TRACE, msg, null, th); } /** @@ -163,11 +173,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param msg */ public void debug(EELFLogger logger, String msg) { - if (logger.isDebugEnabled()) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.debug(msg); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); - } + logWrite(logger, Level.DEBUG, msg, null); } /** @@ -178,11 +184,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param arguments */ public void debug(EELFLogger logger, String msg, Object... arguments) { - if (logger.isDebugEnabled()) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.debug(msg, arguments); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); - } + logWrite(logger, Level.DEBUG, msg, null, arguments); } /** @@ -193,11 +195,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param th */ public void debug(EELFLogger logger, String msg, Throwable th) { - if (logger.isDebugEnabled()) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.debug(msg, th); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); - } + logWrite(logger, Level.DEBUG, msg, null, th); } /** @@ -208,7 +206,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { */ public void info(EELFLogger logger, String msg) { MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.info(msg); + logWrite(logger, Level.INFO, msg, null); MDC.remove(LoggerProperties.MDC_CLASS_NAME); } @@ -221,8 +219,9 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { */ public void info(EELFLogger logger, String msg, Object... arguments) { MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.info(msg, arguments); + logWrite(logger, Level.INFO, msg, null, arguments); MDC.remove(LoggerProperties.MDC_CLASS_NAME); + } /** @@ -234,8 +233,9 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { */ public void info(EELFLogger logger, String msg, Throwable th) { MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.info(msg, th); + logWrite(logger, Level.INFO, msg, null, th); MDC.remove(LoggerProperties.MDC_CLASS_NAME); + } /** @@ -246,7 +246,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { */ public void warn(EELFLogger logger, String msg) { MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.warn(msg); + logWrite(logger, Level.WARN, msg, null); MDC.remove(LoggerProperties.MDC_CLASS_NAME); } @@ -259,7 +259,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { */ public void warn(EELFLogger logger, String msg, Object... arguments) { MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.warn(msg, arguments); + logWrite(logger, Level.WARN, msg, null, arguments); MDC.remove(LoggerProperties.MDC_CLASS_NAME); } @@ -272,7 +272,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { */ public void warn(EELFLogger logger, String msg, Throwable th) { MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.warn(msg, th); + logWrite(logger, Level.WARN, msg, null, th); MDC.remove(LoggerProperties.MDC_CLASS_NAME); } @@ -284,7 +284,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { */ public void error(EELFLogger logger, String msg) { MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.error(msg); + logWrite(logger, Level.ERROR, msg, null); MDC.remove(LoggerProperties.MDC_CLASS_NAME); } @@ -297,7 +297,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { */ public void error(EELFLogger logger, String msg, Object... arguments) { MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.error(msg, arguments); + logWrite(logger, Level.ERROR, msg, null, arguments); MDC.remove(LoggerProperties.MDC_CLASS_NAME); } @@ -310,7 +310,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { */ public void error(EELFLogger logger, String msg, Throwable th) { MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.error(msg, th); + logWrite(logger, Level.ERROR, msg, null); MDC.remove(LoggerProperties.MDC_CLASS_NAME); } @@ -324,44 +324,24 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { public void error(EELFLogger logger, String msg, AlarmSeverityEnum severtiy) { MDC.put(MDC_ALERT_SEVERITY, severtiy.name()); MDC.put(LoggerProperties.MDC_CLASS_NAME, className); - logger.error(msg); - MDC.remove(MDC_ALERT_SEVERITY); + logWrite(logger, Level.ERROR, msg, null); MDC.remove(LoggerProperties.MDC_CLASS_NAME); + MDC.remove(MDC_ALERT_SEVERITY); } /** * Initializes the logger context. */ - public void init() { + public void init(String appName) { setGlobalLoggingContext(); - final String msg = "############################ Logging is started. ############################"; - // These loggers emit the current date-time without being told. - info(applicationLogger, msg); - error(errorLogger, msg); - debug(debugLogger, msg); - // Audit and metrics logger must be told start AND stop times - final String currentDateTime = getCurrentDateTimeUTC(); - // Set the MDC with audit properties - MDC.put(LoggerProperties.AUDITLOG_BEGIN_TIMESTAMP, currentDateTime); - MDC.put(LoggerProperties.AUDITLOG_END_TIMESTAMP, currentDateTime); - info(auditLogger, msg); - MDC.remove(LoggerProperties.AUDITLOG_BEGIN_TIMESTAMP); - MDC.remove(LoggerProperties.AUDITLOG_END_TIMESTAMP); - // Set the MDC with metrics properties - MDC.put(LoggerProperties.METRICSLOG_BEGIN_TIMESTAMP, currentDateTime); - MDC.put(LoggerProperties.METRICSLOG_END_TIMESTAMP, currentDateTime); - info(metricsLogger, msg); - MDC.remove(LoggerProperties.METRICSLOG_BEGIN_TIMESTAMP); - MDC.remove(LoggerProperties.METRICSLOG_END_TIMESTAMP); + MDC.put(MDC_SERVICE_NAME, appName); } - - + public static String getCurrentDateTimeUTC() { String currentDateTime = ecompLogDateFormat.format(new Date()); return currentDateTime; } - /** * Logs a standard message identified by the specified enum, using the specified * parameters, at error level. Alarm and error severity are taken from the @@ -451,60 +431,56 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param req * @param appName */ - public void setRequestBasedDefaultsIntoGlobalLoggingContext(HttpServletRequest req, String appName,String reqId,String loginId) {// Load the default fields + public void setRequestBasedDefaultsIntoGlobalLoggingContext(HttpServletRequest req, String appName, String reqId, + String loginId) {// Load the default fields // Load the default fields - setGlobalLoggingContext(); - - // Load the request based fields - if (req != null) { - // Load the Request into MDC context. - - MDC.put(MDC_KEY_REQUEST_ID, reqId); - - // Load user agent into MDC context, if available. - String accessingClient = req.getHeader(LoggerProperties.USERAGENT_NAME); - if (accessingClient != null && !"".equals(accessingClient) && (accessingClient.contains("Mozilla") - || accessingClient.contains("Chrome") || accessingClient.contains("Safari"))) { - accessingClient = appName + "_FE"; - } - MDC.put(LoggerProperties.PARTNER_NAME, accessingClient); - - // Protocol, Rest URL & Rest Path - MDC.put(LoggerProperties.FULL_URL, LoggerProperties.UNKNOWN); - MDC.put(LoggerProperties.PROTOCOL, LoggerProperties.HTTP); - String restURL = getFullURL(req); - if (restURL != null && restURL != "") { - MDC.put(LoggerProperties.FULL_URL, restURL); - if (restURL.toLowerCase().contains("https")) { - MDC.put(LoggerProperties.PROTOCOL, LoggerProperties.HTTPS); - } - } - - // Rest Path - MDC.put(MDC_SERVICE_NAME, req.getServletPath()); - - // Client IPAddress i.e. IPAddress of the remote host who is making - // this request. - String clientIPAddress = req.getHeader("X-FORWARDED-FOR"); - if (clientIPAddress == null) { - clientIPAddress = req.getRemoteAddr(); - } - MDC.put(LoggerProperties.CLIENT_IP_ADDRESS, clientIPAddress); - - // Load loginId into MDC context. - MDC.put(LoggerProperties.MDC_LOGIN_ID, "Unknown"); - - - - if (loginId != null && loginId != "") { - MDC.put(LoggerProperties.MDC_LOGIN_ID, loginId); - } + setGlobalLoggingContext(); + + // Load the request based fields + if (req != null) { + // Load the Request into MDC context. + + MDC.put(MDC_KEY_REQUEST_ID, reqId); + + // Load user agent into MDC context, if available. + String accessingClient = req.getHeader(LoggerProperties.USERAGENT_NAME); + if (accessingClient != null && !"".equals(accessingClient) && (accessingClient.contains("Mozilla") + || accessingClient.contains("Chrome") || accessingClient.contains("Safari"))) { + accessingClient = appName + "_FE"; + } + MDC.put(LoggerProperties.PARTNER_NAME, accessingClient); + + // Protocol, Rest URL & Rest Path + MDC.put(LoggerProperties.FULL_URL, LoggerProperties.UNKNOWN); + MDC.put(LoggerProperties.PROTOCOL, LoggerProperties.HTTP); + String restURL = getFullURL(req); + if (restURL != null && restURL != "") { + MDC.put(LoggerProperties.FULL_URL, restURL); + if (restURL.toLowerCase().contains("https")) { + MDC.put(LoggerProperties.PROTOCOL, LoggerProperties.HTTPS); } + } + + // Rest Path + MDC.put(MDC_SERVICE_NAME, req.getServletPath()); + + // Client IPAddress i.e. IPAddress of the remote host who is making + // this request. + String clientIPAddress = req.getHeader("X-FORWARDED-FOR"); + if (clientIPAddress == null) { + clientIPAddress = req.getRemoteAddr(); + } + MDC.put(LoggerProperties.CLIENT_IP_ADDRESS, clientIPAddress); + + // Load loginId into MDC context. + MDC.put(LoggerProperties.MDC_LOGIN_ID, "Unknown"); + + if (loginId != null && loginId != "") { + MDC.put(LoggerProperties.MDC_LOGIN_ID, loginId); + } + } } - - - public static String getFullURL(HttpServletRequest request) { if (request != null) { StringBuffer requestURL = request.getRequestURL(); diff --git a/ecomp-sdk/epsdk-music/pom.xml b/ecomp-sdk/epsdk-music/pom.xml index f7de89e7..553dcf8a 100644 --- a/ecomp-sdk/epsdk-music/pom.xml +++ b/ecomp-sdk/epsdk-music/pom.xml @@ -5,12 +5,12 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-music</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> <packaging>jar</packaging> <name>ONAP Portal SDK Music</name> diff --git a/ecomp-sdk/epsdk-workflow/pom.xml b/ecomp-sdk/epsdk-workflow/pom.xml index d07db16f..83e819a1 100644 --- a/ecomp-sdk/epsdk-workflow/pom.xml +++ b/ecomp-sdk/epsdk-workflow/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> </parent> <!-- GroupId is inherited from parent --> diff --git a/ecomp-sdk/pom.xml b/ecomp-sdk/pom.xml index 2c16ed1e..d65b84a8 100644 --- a/ecomp-sdk/pom.xml +++ b/ecomp-sdk/pom.xml @@ -13,7 +13,7 @@ <!-- Portal SDK Maven parent project --> <groupId>org.onap.portal.sdk</groupId> <artifactId>epsdk-project</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.4.0-SNAPSHOT</version> <packaging>pom</packaging> <name>portal-sdk</name> <url>https://wiki.onap.org/display/DW/Portal</url> |