If you develop a Spring Framework application, it is recommended that you migrate from bugsnag-java to bugsnag-spring. bugsnag-spring adds support for various Spring-specific features, such as automatic detection of exceptions within scheduled tasks. To upgrade:
-
Replace the
bugsnag
artifact withbugsnag-spring
in your build.gradle://compile 'com.bugsnag:bugsnag:3.+' compile 'com.bugsnag:bugsnag-spring:3.+'
-
Create a Spring
Configuration
class which exposesBugsnag
as a Spring bean and imports the configuration classBugsnagSpringConfiguration
. This should replace any previous instantiation ofBugsnag
:@Configuration @Import(BugsnagSpringConfiguration.class) public class BugsnagConfig { @Bean public Bugsnag bugsnag() { return new Bugsnag("your-api-key-here"); } }
-
If you wish to configure Logback, capture uncaught exceptions in async methods, or otherwise customise your integration, please see the docs for further information.
The Java notifier library has gone through some major improvements, and there are some small changes you'll need to make to upgrade.
Java 1.6 and above is now required.
The main Client
class has been renamed to Bugsnag
. The Event
class (used in callbacks) has been renamed to Report
.
Severity
is now an enum instead of a String
.
Java 8 Lambda syntax is now supported in callbacks. For example:
bugsnag.addCallback((report) -> {
report.setSeverity(Severity.ERROR);
});
or from a bugsnag.notify() call:
bugsnag.notify(ex, (report) -> {
report.addToTab("tab", "key", "value");
});
Chaining support added to Report
methods:
bugsnag.addCallback((report) -> {
report.setSeverity(Severity.ERROR).setUserId("123");
});
Setting a custom endpoint now requires the protocol to be set:
bugsnag.setEndpoint("https://bugsnag.internal.example:49000");