Logger_common_impl swallows exception
Added workardound to by pulling the throwable from the args list and providing it explicitly if the last argument in the args list is a throwable
@@ -283,8 +283,19 @@ public class Slf4jLogger_impl extends Logger_common_impl {
m = (m == null) ? getMarkerForLevel(level) : m;
if (isLocationCapable) { // slf4j simple logger is not
+ // Work around LOG4J2-3177 by pulling a throwable from the args and providing it as thrown
+ // to the logger
+ Throwable actualThrown = thrown;
+ Object[] actualArgs = args;
+ if (actualThrown == null && args != null && args.length > 0
+ && args[args.length - 1] instanceof Throwable) {
+ actualThrown = (Throwable) args[args.length - 1];
+ actualArgs = new Object[args.length - 1];
+ System.arraycopy(args, 0, actualArgs, 0, actualArgs.length);
+ }
+
((org.slf4j.spi.LocationAwareLogger) logger).log(m, aFqcn, getSlf4jLevel(level), message,
- args, thrown);
+ actualArgs, actualThrown);
} else {
if (thrown != null) {
Object[] args1 = (args == null) ? new Object[1] : new Object[args.length + 1];
