summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunder Tattavarada <statta@att.com>2020-10-26 13:45:21 +0000
committerGerrit Code Review <gerrit@onap.org>2020-10-26 13:45:21 +0000
commit341a13377a3670abe171bc14c846e9f54c57ded1 (patch)
tree5f0350ef5a883845dd784dc1100c3705890934d6
parentbdb6c3331987301932ffc417e359a5af9247a142 (diff)
parentf05c67c2d001d14b0ee564cd7650eea974e578e0 (diff)
Merge "Getting stack trace in debug log and error message in error log"
-rw-r--r--ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java15
1 files changed, 13 insertions, 2 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 b28bcf5a..f74571b5 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
@@ -47,6 +47,7 @@ import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
import java.net.InetAddress;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
+import java.util.Arrays;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@@ -134,7 +135,14 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
}
if (logger.isErrorEnabled()) {
- logger.log(level, msg, null, arguments);
+ Object[] transformedArgs = Arrays.stream(arguments).map(argument -> {
+ if (argument instanceof Throwable)
+ return ((Throwable) argument).getMessage();
+ else
+ return argument;
+ }).toArray();
+ logger.log(level, msg, null, transformedArgs);
+ debugLogger.error(msg, arguments);
} else {
logger.log(level, msg, th, arguments);
}
@@ -350,7 +358,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
* @param th
*/
public void error(EELFLogger logger, String msg, Throwable th) {
- logWrite(logger, Level.ERROR, msg, null);
+ logWrite(logger, Level.ERROR, msg, null, th);
}
/**
@@ -407,6 +415,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
} catch (Exception e) {
validateErrorLogFields();
errorLogger.error("logEcompError failed " + e.getMessage());
+ debugLogger.error("logEcompError failed " , e);
} finally {
MDC.remove(LoggerProperties.ERROR_CODE);
MDC.remove(LoggerProperties.ERROR_DESCRIPTION);
@@ -446,6 +455,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
} catch (Exception e) {
validateErrorLogFields();
errorLogger.error("setGlobalLoggingContext failed " + e.getMessage());
+ debugLogger.error("setGlobalLoggingContext failed ", e);
}
}
@@ -548,6 +558,7 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
} catch (Exception e) {
validateErrorLogFields();
errorLogger.error("calculateDateTimeDifference failed " + e.getMessage());
+ debugLogger.error("calculateDateTimeDifference failed ", e);
}
}
}