Closed abhishekpargal12 closed 2 years ago
Add the javabrake dependency through your IDE or directly to your pom.xml file:
pom.xml
<dependency> <groupId>io.airbrake</groupId> <artifactId>javabrake</artifactId> <version>0.2.4</version> </dependency>
Add javabrake to your Gradle dependencies:
compile 'io.airbrake:javabrake:0.2.4'
Add javabrake to your Ivy dependencies:
<dependency org='io.airbrake' name='javabrake' rev='0.2.4'> <artifact name='javabrake' ext='pom'></artifact> </dependency>
Import the Airbrake library, configure it, and then use it to report errors to Airbrake. Airbrake also integrates with libraries like log4j2 and logback.
(You can find your project ID and API key in your project's settings)
import io.airbrake.javabrake.Notifier; import io.airbrake.javabrake.Config; Config config = new Config(); config.projectId = <Your project ID>; config.projectKey = "<Your project API KEY>"; Notifier notifier = new Notifier(config); notifier.addFilter( (Notice notice) -> { notice.setContext("environment", "production"); return notice; });
Example of reporting a caught exception using notifier directly:
notifier
try { do(); } catch (IOException e) { notifier.report(e); }
Example using the Airbrake proxy class:
Airbrake
try { do(); } catch (IOException e) { Airbrake.report(e); }
Visit our official GitHub repo for advanced information and integrations like log4j, log4j2, and logback.
Installation
Install option 1: Maven
Add the javabrake dependency through your IDE or directly to your
pom.xml
file:Install option 2: Gradle
Add javabrake to your Gradle dependencies:
Install option 3: Ivy
Add javabrake to your Ivy dependencies:
Configuration
Import the Airbrake library, configure it, and then use it to report errors to Airbrake. Airbrake also integrates with libraries like log4j2 and logback.
(You can find your project ID and API key in your project's settings)
Example of reporting a caught exception using
notifier
directly:Example using the
Airbrake
proxy class:Full documentation
Visit our official GitHub repo for advanced information and integrations like log4j, log4j2, and logback.