Honeybadger :: Java :: Client

Honeybadger Client

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.workable.honeybadger
ArtifactId

ArtifactId

honeybadger-client
Last Version

Last Version

1.5.4
Release Date

Release Date

Type

Type

jar
Description

Description

Honeybadger :: Java :: Client
Honeybadger Client
Project URL

Project URL

https://github.com/Workable/honeybadger-java/wiki/honeybadger-client

Download honeybadger-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.workable.honeybadger/honeybadger-client/ -->
<dependency>
    <groupId>com.workable.honeybadger</groupId>
    <artifactId>honeybadger-client</artifactId>
    <version>1.5.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.workable.honeybadger/honeybadger-client/
implementation 'com.workable.honeybadger:honeybadger-client:1.5.4'
// https://jarcasting.com/artifacts/com.workable.honeybadger/honeybadger-client/
implementation ("com.workable.honeybadger:honeybadger-client:1.5.4")
'com.workable.honeybadger:honeybadger-client:jar:1.5.4'
<dependency org="com.workable.honeybadger" name="honeybadger-client" rev="1.5.4">
  <artifact name="honeybadger-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.workable.honeybadger', module='honeybadger-client', version='1.5.4')
)
libraryDependencies += "com.workable.honeybadger" % "honeybadger-client" % "1.5.4"
[com.workable.honeybadger/honeybadger-client "1.5.4"]

Dependencies

compile (3)

Group / Artifact Type Version
com.google.code.gson : gson jar 2.3.1
org.slf4j : slf4j-api jar 1.7.7
org.apache.httpcomponents : httpclient jar 4.2.5

provided (1)

Group / Artifact Type Version
javax.servlet : servlet-api jar 2.5

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.hamcrest : hamcrest-all jar 1.3

Project Modules

There are no modules declared in this project.

Honeybadger-java

Java client to report exceptions to Honeybadger.io

Exceptions can be captured and dispatched in Honeybadger with the following methods:

Usage

Standalone

A typical stand-alone implementation may look like:

import com.workable.honeybadger.HoneybadgerUncaughtExceptionHandler;

public static void main(String argv[]) {
    HoneybadgerUncaughtExceptionHandler.registerAsUncaughtExceptionHandler();
    // The rest of the application goes here
}

The following system properties should be set to enable error dispatching:

System Properties:

  • honeybadger.api_key - set this to the (typically 8 character) API key displayed on your Honeybadger interface
  • honeybadger.excluded_sys_props - a comma delinated list of system property keys to exclude from being reported to Honeybadger. This allows you to prevent passwords and other sensitive information from being sent.
  • honeybadger.excluded_exception_classes - a comma delimited list of fully formed class names that will be excluded from error reporting.
  • JAVA_ENV / ENV - set this to configure the application's running environment

In a servlet container

A servlet based implemantion may look like:

In your web.xml file:

    <!-- Send all uncaught servlet exceptions and servlet request details to Honeybadger -->
    <filter>
        <filter-name>HoneybadgerFilter</filter-name>
        <filter-class>com.workable.honeybadger.servlet.HoneybadgerFilter</filter-class>
        <init-param>
            <param-name>honeybadger.api_key</param-name>
            <param-value>API KEY GOES HERE</param-value>
        </init-param>
        <init-param>
            <param-name>honeybadger.excluded_sys_props</param-name>
            <param-value>bonecp.password,bonecp.username</param-value>
        </init-param>
        <init-param>
            <param-name>honeybadger.excluded_exception_classes</param-name>
            <param-value>org.apache.catalina.connector.ClientAbortException</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>HoneybadgerFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

Log4J

A typical log4j properties may look like:

log4j.rootLogger=ALL, ConsoleAppender, HoneybadgerAppender

log4j.appender.HoneybadgerAppender=com.workable.honeybadger.log4j.HoneybadgerAppender
log4j.appender.HoneybadgerAppender.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.HoneybadgerAppender.layout.ConversionPattern=[%-5p] %c - %m%n%throwable{none}
log4j.appender.HoneybadgerAppender.threshold=ERROR

log4j.appender.HoneybadgerAppender.apiKey=XXXXXXXX
log4j.appender.HoneybadgerAppender.async=true
log4j.appender.HoneybadgerAppender.maxThreads=1
log4j.appender.HoneybadgerAppender.queueSize=50000
log4j.appender.HoneybadgerAppender.priority=1


log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender
log4j.appender.ConsoleAppender.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.ConsoleAppender.layout.ConversionPattern=[WORKABLE] [%-5p] %c - %m%n%throwable{none}

Logback

A typical logback.xml may look like:

<configuration>
    <appender name="honeybadger" class="com.workable.honeybadger.logback.HoneybadgerAppender">
        <param name="Threshold" value="ERROR" />
        <param name="apiKey" value="xxxxxx" />
        <encoder>
            <pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
        </encoder>
    </appender>
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
        </encoder>
    </appender>
    <logger name="com.workable">
        <level value="DEBUG"/>
    </logger>
    <root>
        <level value="INFO" />
        <appender-ref ref="honeybadger" />
        <appender-ref ref="console" />
    </root>
</configuration>
com.workable.honeybadger

Versions

Version
1.5.4
1.5.3
1.5.2
1.5.1
1.5
1.4
1.3
1.2