summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-logger/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-logger/src/main/java')
-rw-r--r--ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java43
-rw-r--r--ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/LoggerProperties.java2
2 files changed, 23 insertions, 22 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 45eae6d4..21290f59 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
@@ -120,10 +120,9 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
}
if ( logger == errorLogger) {
- if(MDC.get(LoggerProperties.MDC_CLASS_NAME) == null) {
- MDC.put(LoggerProperties.MDC_CLASS_NAME, className);
+ if(MDC.get(LoggerProperties.ERROR_CATAGORY) == null||MDC.get(LoggerProperties.ERROR_CATAGORY).isEmpty()) {
+ MDC.put(LoggerProperties.ERROR_CATAGORY, ErrorSeverityEnum.ERROR.name());
}
- MDC.put(MDC_ALERT_SEVERITY, AlarmSeverityEnum.ERROR.name());
if(MDC.get(LoggerProperties.ERROR_CODE) == null) {
MDC.put(LoggerProperties.ERROR_CODE, "900");
}
@@ -142,7 +141,6 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
}
if ( logger == auditLogger) {
- MDC.put(LoggerProperties.MDC_CLASS_NAME, className);
this.calculateDateTimeDifference(MDC.get(LoggerProperties.AUDITLOG_BEGIN_TIMESTAMP), MDC.get(LoggerProperties.AUDITLOG_END_TIMESTAMP));
MDC.put(LoggerProperties.CUSTOM_FIELD1, "EXIT");
MDC.put(LoggerProperties.CUSTOM_FIELD2, "InvocationID=" + requestId);
@@ -153,23 +151,26 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
} else {
logger.log(level, msg, th, arguments);
}
-
- if ( logger == errorLogger) {
- MDC.remove(LoggerProperties.MDC_CLASS_NAME);
- MDC.remove(LoggerProperties.ERROR_CATAGORY);
- MDC.remove(LoggerProperties.ERROR_CODE);
- MDC.remove(LoggerProperties.ERROR_DESCRIPTION);
- }
-
- if(logger == auditLogger) {
- MDC.remove(LoggerProperties.MDC_CLASS_NAME);
- MDC.remove(LoggerProperties.CUSTOM_FIELD1);
- MDC.remove(LoggerProperties.CUSTOM_FIELD2);
- }
+ tearDownMDC();
+ }
+
+ /**
+ * remove the logger context.
+ */
+ public void tearDownMDC() {
+ MDC.remove(LoggerProperties.ERROR_CATAGORY);
+ MDC.remove(LoggerProperties.ERROR_CODE);
+ MDC.remove(LoggerProperties.ERROR_DESCRIPTION);
+ MDC.remove(LoggerProperties.MDC_TIMER);
+ MDC.remove(LoggerProperties.CUSTOM_FIELD1);
+ MDC.remove(LoggerProperties.CUSTOM_FIELD2);
MDC.remove(MDC_KEY_REQUEST_ID);
-
+ MDC.remove(LoggerProperties.STATUS_CODE);
+ MDC.remove(LoggerProperties.PARTNER_NAME);
+
}
+
/**
* Logs a message at the lowest level: trace.
*
@@ -384,7 +385,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
errorLogger.error(resolution);
}
} catch (Exception e) {
- errorLogger.error("logEcompError failed", e);
+ errorLogger.error("logEcompError failed " + e.getMessage());
} finally {
MDC.remove(LoggerProperties.ERROR_CODE);
MDC.remove(LoggerProperties.ERROR_DESCRIPTION);
@@ -422,7 +423,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
MDC.put(MDC_SERVICE_NAME, LoggerProperties.getPropertyValue(LoggerProperties.APP_NAME));
} catch (Exception e) {
- errorLogger.error("setGlobalLoggingContext failed", e);
+ errorLogger.error("setGlobalLoggingContext failed " + e.getMessage());
}
}
@@ -523,7 +524,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
String timeDifference = String.format("%d", endDate.getTime() - beginDate.getTime());
MDC.put(LoggerProperties.MDC_TIMER, timeDifference);
} catch (Exception e) {
- errorLogger.error("calculateDateTimeDifference failed", e);
+ errorLogger.error("calculateDateTimeDifference failed " + e.getMessage());
}
}
}
diff --git a/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/LoggerProperties.java b/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/LoggerProperties.java
index 4287088b..003929e6 100644
--- a/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/LoggerProperties.java
+++ b/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/LoggerProperties.java
@@ -82,7 +82,7 @@ public class LoggerProperties {
public static final String USER_ATTRIBUTE_NAME = "user_attribute_name";
public static final String ALERT_SEVERITY = "AlertSeverity";
- public static final String ERROR_CATAGORY = "ErrorCatagory";
+ public static final String ERROR_CATAGORY = "ErrorCategory";
public static final String ERROR_CODE = "ErrorCode";
public static final String ERROR_DESCRIPTION = "ErrorDescription";
public static final String CUSTOM_FIELD1 = "CustomField1";