diff options
author | 2020-10-23 09:44:34 -0400 | |
---|---|---|
committer | 2020-10-23 13:11:17 -0400 | |
commit | f05c67c2d001d14b0ee564cd7650eea974e578e0 (patch) | |
tree | 827a7a8a4fa109aa7a9e403974103731c0c2ea90 /ecomp-sdk | |
parent | 84664e840caea5628664ac466a26c3be0eec0b27 (diff) |
Getting stack trace in debug log and error message in error log
Issue-ID: PORTAL-1008
Signed-off-by: Kishore Reddy Dwaram <kishore.reddy.dwaram@att.com>
Change-Id: I59cf6773316316233157acfb0db7182381bdc8cd
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); } } } |