diff options
author | Sunder Tattavarada <statta@att.com> | 2020-10-26 13:45:21 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-10-26 13:45:21 +0000 |
commit | 341a13377a3670abe171bc14c846e9f54c57ded1 (patch) | |
tree | 5f0350ef5a883845dd784dc1100c3705890934d6 /ecomp-sdk | |
parent | bdb6c3331987301932ffc417e359a5af9247a142 (diff) | |
parent | f05c67c2d001d14b0ee564cd7650eea974e578e0 (diff) |
Merge "Getting stack trace in debug log and error message in error log"
Diffstat (limited to 'ecomp-sdk')
-rw-r--r-- | ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java | 15 |
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); } } } |