Honeybadger :: Java :: Logback Appender

Logback appender allowing to send logs to Honeybadger.

License

License

Categories

Categories

Logback Application Layer Libs Logging
GroupId

GroupId

com.workable.honeybadger
ArtifactId

ArtifactId

honeybadger-logback-appender
Last Version

Last Version

1.5.4
Release Date

Release Date

Type

Type

jar
Description

Description

Honeybadger :: Java :: Logback Appender
Logback appender allowing to send logs to Honeybadger.
Project URL

Project URL

https://github.com/Workable/honeybadger-java/wiki/honeybadger-logback-appender

Download honeybadger-logback-appender

How to add to project

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

Dependencies

compile (5)

Group / Artifact Type Version
com.workable.honeybadger : honeybadger-client jar 1.5.4
ch.qos.logback : logback-classic jar 1.1.2
ch.qos.logback : logback-core jar 1.1.2
com.google.guava : guava jar 18.0
junit : junit jar 4.11

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