I have Java code that looks a bit like the sample below.
The library I’m using logs warnings and errors with slf4j.
All the errors are send to Sentry because I’m using a log4j appender to Sentry.
What I would like is that if the catch is reached, I would get a Sentry issue with a log of all the previous events.
The problem is that the library I’m using isn’t my own and when there is an error, the authors ask for a complete log. Not only the last error.
Is that possible?
new Thread(() -> {
try {
Sentry.getContext().recordBreadcrumb(
new BreadcrumbBuilder().setMessage("Start Session").build()
);
Library library = new Library()
library.StartSomethingThatLogsWarningsAndErrors()
} catch (Throwable e) {
logger.error("Error when starting session", e);
}
}).start();