Source:
<code>public void run(final String... args) throws Exception { BugsnagAppender.getInstance().addCallback((report) -> { report.addToTab("diagnostics", "timestamp", new Date()); report.addToTab("customer", "name", "acme-inc"); report.addToTab("customer", "paying", true); report.addToTab("customer", "spent", 1234); report.setUserName("User Name"); report.setUserEmail("user@example.com"); report.setUserId("12345"); }); BugsnagAppender.addThreadMetaData("report", "application", "has started on this thread"); LOGGER.info("Sending a handled exception to Bugsnag"); try { throw new RuntimeException("Handled exception - default severity"); } catch (RuntimeException e) { <START> LOGGER.warn(e.getMessage(), e); <END> } LOGGER.info("Sending a handled exception to Bugsnag with INFO severity"); try { throw new RuntimeException("Handled exception - INFO severity"); } catch (RuntimeException e) { LOGGER.info(e.getMessage(), e); } LOGGER.info("Sending a handled exception to Bugsnag with custom MetaData"); try { throw new RuntimeException("Handled exception - custom metadata"); } catch (RuntimeException e) { BugsnagAppender.addReportMetaData("report", "something", "that happened"); BugsnagAppender.addReportMetaData("report", "something else", "that happened"); LOGGER.warn(e.getMessage(), e); } LOGGER.info("Sending an unhandled exception to Bugsnag"); Thread thread = new Thread() { @Override public void run() { throw new RuntimeException("Unhandled exception"); } }; thread.start(); thread.join(); BugsnagAppender.clearThreadMetaData(); SpringApplication.exit(applicationContext); }</code><technical_language>nice example logs a custom message e.g. LOGGER.warn("Something bad happened", e);</technical_language>

Target:
public void run(final String... args) throws Exception { BugsnagAppender.getInstance().addCallback((report) -> { report.addToTab("diagnostics", "timestamp", new Date()); report.addToTab("customer", "name", "acme-inc"); report.addToTab("customer", "paying", true); report.addToTab("customer", "spent", 1234); report.setUserName("User Name"); report.setUserEmail("user@example.com"); report.setUserId("12345"); }); BugsnagAppender.addThreadMetaData("thread tab", "thread key 1", "thread value 1"); LOGGER.info("Sending a handled exception to Bugsnag"); try { throw new RuntimeException("Handled exception - default severity"); } catch (RuntimeException e) { LOGGER.warn(e.getMessage(), e); } LOGGER.info("Sending a handled exception to Bugsnag with INFO severity"); try { throw new RuntimeException("Handled exception - INFO severity"); } catch (RuntimeException e) { LOGGER.info(e.getMessage(), e); } LOGGER.info("Sending a handled exception to Bugsnag with custom MetaData"); try { throw new RuntimeException("Handled exception - custom metadata"); } catch (RuntimeException e) { LOGGER.warn("Something bad happened", new ExceptionWithCallback(e, report -> { report.addToTab("report tab", "data key 1", "data value 1"); report.addToTab("report tab", "data key 2", "data value 2"); })); } LOGGER.info("Sending an unhandled exception to Bugsnag"); Thread thread = new Thread() { @Override public void run() { throw new RuntimeException("Unhandled exception"); } }; thread.start(); thread.join(); BugsnagAppender.clearThreadMetaData(); SpringApplication.exit(applicationContext); }