Configuration options

All available options for configuring your integration with Bugsnag.

addCallback

Adds a callback which will be invoked directly before the notifier sends the error to Bugsnag. This callback has full read/write access to the error object, so it has the opportunity to cancel the error to prevent it being sent all together.

The callback does not get invoked if the Exception name has been set to ignored via setIgnoreClasses.

By calling report.cancel() in a callback, the Bugsnag notifier will prevent sending the error to the Bugsnag. The first callback to call cancel() will prevent all other subsequent callbacks from being invoked.

bugsnag.addCallback((report) -> {
    // Sets the groupingHash option
    report.setGroupingHash("hello");

    // Overrides the severity
    report.setSeverity(Severity.WARNING);

    // Adds some metadata
    report.addToTab("State", "memory", 12345);

    // Prevent the report from being sent
    report.cancel();
});

Or without using the Java 8 lambda syntax:

import com.bugsnag.callbacks.Callback;
import com.bugsnag.Report;

bugsnag.addCallback(new Callback() {
    @Override
    public void beforeNotify(Report report) {
        // Sets the groupingHash option
        report.setGroupingHash("hello");

        // Overrides the severity
        report.setSeverity(Severity.WARNING);

        // Adds some metadata
        report.addToTab("State", "memory", 12345);

        // Prevent the report from being sent
        report.cancel();
    }
});

setAppType

Set the type of the application, for example spring, gradleTask.

bugsnag.setAppType("gradleTask");

setAppVersion

For client Java applications, for example desktop apps, the version can be set so you’ll be able to see which version each error was introduced in, or seen in.

For server applications, use deploy tracking instead.

bugsnag.setAppVersion("1.0.0");

setDelivery

By default we’ll send reports asynchronously using a thread pool but a different delivery mechanism can be provided by implementing the Delivery interface.

bugsnag.setDelivery(new Delivery() {
    @Override
    public void deliver(Serializer serializer, Object object) {
        // Implement deliver to send reports
    }
});

To send reports synchronously you can use SyncHttpDelivery:

bugsnag.setDelivery(new SyncHttpDelivery());

setEndpoint

By default, we will send errors to your bugsnag.com dashboard. If you are using Bugsnag Enterprise you’ll need to call setEndpoint to specify errors be sent to your Bugsnag Enterprise endpoint:

bugsnag.setEndpoint("https://bugsnag.internal.example:49000");

setFilters

Sets the strings to filter out from the maps before sending them to Bugsnag. Use this if you want to ensure you don’t send sensitive data such as passwords, and credit card numbers to our servers. Any keys which contain these strings will be filtered and displayed in the dashboard as key - [FILTERED].

bugsnag.setFilters("password", "credit_card_number");

By default, filters is set to "password"

setIgnoreClasses

Sets for which exception classes we should not send exceptions to Bugsnag.

bugsnag.setIgnoreClasses("java.io.IOException", "com.example.Custom");

setNotifyReleaseStages

By default, we will notify Bugsnag of exceptions that happen in any releaseStage. If you would like to change which release stages notify Bugsnag of exceptions you can call setNotifyReleaseStages. Also see setReleaseStage.

bugsnag.setNotifyReleaseStages("production", "development");

setProjectPackages

Sets which package names Bugsnag should consider as “in project”. We mark stacktrace lines as in-project if they originate from any of these packages.

bugsnag.setProjectPackages("com.company.package1", "com.company.package2");

setReleaseStage

To distinguish between errors that happen in different stages of the application release process (development, production, etc) you can set the releaseStage that is reported to Bugsnag. Also see setNotifyReleaseStages.

bugsnag.setReleaseStage("development");

Defaults to production.

setSendThreads

Sets if we should collect and send thread state along with errors.

bugsnag.setSendThreads(true);

By default sendThreads is set to false.

setProxy

Sets the proxy to use when sending errors to Bugsnag.

bugsnag.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("example.com", 80));