From 3eca7a1abf78efa079cb8464c254553b27c5b651 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Fri, 8 Nov 2024 20:05:56 +0200 Subject: [PATCH] address review comment --- .../instrumentation/log4j/appender/v2_17/Log4jHelper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instrumentation/log4j/log4j-appender-2.17/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/log4j/appender/v2_17/Log4jHelper.java b/instrumentation/log4j/log4j-appender-2.17/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/log4j/appender/v2_17/Log4jHelper.java index b06d61de517b..6fc308cc1dd9 100644 --- a/instrumentation/log4j/log4j-appender-2.17/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/log4j/appender/v2_17/Log4jHelper.java +++ b/instrumentation/log4j/log4j-appender-2.17/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/log4j/appender/v2_17/Log4jHelper.java @@ -118,15 +118,16 @@ private static StackTraceElement getLocation(String loggerClassName) { } private static MethodHandle getStackTraceMethodHandle() { - // since 2.9.0 Class stackTraceClass = null; try { + // since 2.9.0 stackTraceClass = Class.forName("org.apache.logging.log4j.util.StackLocatorUtil"); } catch (ClassNotFoundException exception) { // ignore } if (stackTraceClass == null) { try { + // before 2.9.0 stackTraceClass = Class.forName("org.apache.logging.log4j.core.impl.Log4jLogEvent"); } catch (ClassNotFoundException exception) { // ignore