diff options
author | Kishore Reddy Dwaram <kishore.reddy.dwaram@att.com> | 2020-09-17 11:22:40 -0400 |
---|---|---|
committer | Kishore Reddy Dwaram <kishore.reddy.dwaram@att.com> | 2020-09-17 17:00:15 -0400 |
commit | 43c4a6ba0fe15350346457d9e8ac2cb4df656b33 (patch) | |
tree | a5dda518526f2dacddb38438709784ce595d9fc3 /ecomp-sdk/epsdk-logger/src | |
parent | 882777cfc554e1eca05d7ba583bc311fd753708b (diff) |
changes in metrics logs
Issue-ID: PORTAL-1008
Change-Id: I007420af6bf5f89862b55b7625f0f2a76d73802f
Signed-off-by: Kishore Reddy Dwaram <kishore.reddy.dwaram@att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-logger/src')
-rw-r--r-- | ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java | 38 |
1 files changed, 14 insertions, 24 deletions
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 2bb1b526..adad5caa 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 @@ -49,8 +49,7 @@ 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.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -61,6 +60,7 @@ import org.onap.portalsdk.core.logging.format.AppMessagesEnum; import org.onap.portalsdk.core.logging.format.ErrorSeverityEnum; import org.slf4j.MDC; +import com.att.eelf.configuration.Configuration; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.att.eelf.configuration.SLF4jWrapper; @@ -112,12 +112,20 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { return delegate; } - public static void logWrite(EELFLogger logger, Level level, String msg, Throwable th, Object... arguments) { - + public void logWrite(EELFLogger logger, Level level, String msg, Throwable th, Object... arguments) { + MDC.put(LoggerProperties.MDC_CLASS_NAME, className); + setGlobalLoggingContext(); if ( logger == errorLogger) { + MDC.put(LoggerProperties.MDC_CLASS_NAME, className); MDC.put("ErrorCategory", ErrorSeverityEnum.ERROR.name()); MDC.put("ErrorCode", "900"); MDC.put("ErrorDescription", "Exception"); + + } + + if (MDC.get(Configuration.MDC_KEY_REQUEST_ID) == null||MDC.get(Configuration.MDC_KEY_REQUEST_ID).isEmpty()){ + String requestId = UUID.randomUUID().toString(); + MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId); } if (logger.isErrorEnabled()) { @@ -127,6 +135,8 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { } if ( logger == errorLogger) { + MDC.remove(MDC_SERVICE_NAME); + MDC.remove(LoggerProperties.MDC_CLASS_NAME); MDC.remove("ErrorCode"); MDC.remove("ErrorDescription"); MDC.remove("ErrorCategory"); @@ -205,9 +215,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param msg */ public void info(EELFLogger logger, String msg) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); logWrite(logger, Level.INFO, msg, null); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); } /** @@ -218,9 +226,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param arguments */ public void info(EELFLogger logger, String msg, Object... arguments) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); logWrite(logger, Level.INFO, msg, null, arguments); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); } @@ -232,9 +238,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param th */ public void info(EELFLogger logger, String msg, Throwable th) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); logWrite(logger, Level.INFO, msg, null, th); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); } @@ -245,9 +249,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param msg */ public void warn(EELFLogger logger, String msg) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); logWrite(logger, Level.WARN, msg, null); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); } /** @@ -258,9 +260,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param arguments */ public void warn(EELFLogger logger, String msg, Object... arguments) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); logWrite(logger, Level.WARN, msg, null, arguments); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); } /** @@ -271,9 +271,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param th */ public void warn(EELFLogger logger, String msg, Throwable th) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); logWrite(logger, Level.WARN, msg, null, th); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); } /** @@ -283,9 +281,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param msg */ public void error(EELFLogger logger, String msg) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); logWrite(logger, Level.ERROR, msg, null); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); } /** @@ -296,9 +292,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param arguments */ public void error(EELFLogger logger, String msg, Object... arguments) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); logWrite(logger, Level.ERROR, msg, null, arguments); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); } /** @@ -309,9 +303,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { * @param th */ public void error(EELFLogger logger, String msg, Throwable th) { - MDC.put(LoggerProperties.MDC_CLASS_NAME, className); logWrite(logger, Level.ERROR, msg, null); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); } /** @@ -323,9 +315,7 @@ 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); logWrite(logger, Level.ERROR, msg, null); - MDC.remove(LoggerProperties.MDC_CLASS_NAME); MDC.remove(MDC_ALERT_SEVERITY); } |