Honeybadger :: Java

Honeybadger Java parent project.

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.workable.honeybadger
ArtifactId

ArtifactId

honeybadger-java
Last Version

Last Version

1.5.4
Release Date

Release Date

Type

Type

pom
Description

Description

Honeybadger :: Java
Honeybadger Java parent project.
Project URL

Project URL

https://github.com/Workable/honeybadger-java/wiki
Source Code Management

Source Code Management

http://github.com/Workable/honeybadger-java

Download honeybadger-java

How to add to project

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

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • honeybadger-client
  • honeybadger-log4j-appender
  • honeybadger-logback-appender

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