From 4ed93eb9fcd75ddc67b77dcce2cc5b33c959c446 Mon Sep 17 00:00:00 2001 From: StrikeW Date: Mon, 16 Dec 2024 22:39:21 +0800 Subject: [PATCH] fix(log): print java exception stack trace in logger (#19814) --- .../tracing/TracingSlf4jAdapter.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/java/connector-node/tracing/src/main/java/com/risingwave/tracing/TracingSlf4jAdapter.java b/java/connector-node/tracing/src/main/java/com/risingwave/tracing/TracingSlf4jAdapter.java index e0aee7633c518..63be7fe4439e6 100644 --- a/java/connector-node/tracing/src/main/java/com/risingwave/tracing/TracingSlf4jAdapter.java +++ b/java/connector-node/tracing/src/main/java/com/risingwave/tracing/TracingSlf4jAdapter.java @@ -36,17 +36,23 @@ private void logIfEnabled(int level, String msg) { private void logIfEnabled(int level, String format, Object arg) { if (TracingSlf4jImpl.isEnabled(level)) { - TracingSlf4jImpl.event( - name, level, new ParameterizedMessage(format, arg).getFormattedMessage()); + var pm = new ParameterizedMessage(format, arg); + if (null != pm.getThrowable()) { + logIfEnabled(level, pm.getFormattedMessage(), pm.getThrowable()); + } else { + TracingSlf4jImpl.event(name, level, pm.getFormattedMessage()); + } } } private void logIfEnabled(int level, String format, Object arg1, Object arg2) { if (TracingSlf4jImpl.isEnabled(level)) { - TracingSlf4jImpl.event( - name, - level, - new ParameterizedMessage(format, arg1, arg2).getFormattedMessage()); + var pm = new ParameterizedMessage(format, arg1, arg2); + if (null != pm.getThrowable()) { + logIfEnabled(level, pm.getFormattedMessage(), pm.getThrowable()); + } else { + TracingSlf4jImpl.event(name, level, pm.getFormattedMessage()); + } } }