I am trying to make Sentry work with a maven/Java project. It seems that I can initialize a connection to the Sentry server, however only errors that I specifically catch with Sentry.capture(e) gets loaded to the server. How can I make it so that EVERY uncaught error will be loaded to the server?
I am using the environment variables, and I'm using intelliJ. In "Run" -> "Edit Configurations..." -> "Environment Variables"
And I inserted SENTRY_DNS="myDNS" SENTRY_SAMPLE_RATE="0.75" as shown in the docs... Do I lack something?
It depends on your application.
If you are already using a logging framework (log4j, log4j2, logback or java.util.logging) you could use one of those integrations to automatically capture any logger.error
calls: https://docs.sentry.io/clients/java/modules/
If you aren't using a logging framework, or you want to capture other exceptions, then you need to manually capture them with Sentry.capture(...)
.
Does your application have a main run loop? If it's a server of some kind there is typically a place you can insert a single Sentry.capture(...)
in the main try
/catch
loop. If it's a one-off CLI application then you can just wrap the entire main
method body.