diff --git a/CHANGELOG.md b/CHANGELOG.md index 18713588b48..26efd475402 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ ### Fixes - Fix main thread identification for tombstone (native crash) events ([#5742](https://github.com/getsentry/sentry-java/pull/5742)) +- Replace deprecated `ThrowableProxy` with `LogEvent#getThrown()` in `sentry-log4j2` ([#5751](https://github.com/getsentry/sentry-java/pull/5751)) + ### Dependencies diff --git a/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java b/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java index df0f9eeb2d2..0218b53518d 100644 --- a/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java +++ b/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java @@ -41,7 +41,6 @@ import org.apache.logging.log4j.core.config.plugins.PluginAttribute; import org.apache.logging.log4j.core.config.plugins.PluginElement; import org.apache.logging.log4j.core.config.plugins.PluginFactory; -import org.apache.logging.log4j.core.impl.ThrowableProxy; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -274,13 +273,12 @@ protected void captureLog(@NotNull LogEvent loggingEvent) { event.setLogger(loggingEvent.getLoggerName()); event.setLevel(formatLevel(loggingEvent.getLevel())); - final ThrowableProxy throwableInformation = loggingEvent.getThrownProxy(); - if (throwableInformation != null) { + final @Nullable Throwable thrown = loggingEvent.getThrown(); + if (thrown != null) { final Mechanism mechanism = new Mechanism(); mechanism.setType(MECHANISM_TYPE); final Throwable mechanismException = - new ExceptionMechanismException( - mechanism, throwableInformation.getThrowable(), Thread.currentThread()); + new ExceptionMechanismException(mechanism, thrown, Thread.currentThread()); event.setThrowable(mechanismException); }