PricingBlogDocumentationDocsLoginRegister

Connect your Logback project to GlitchTip

Installation

Using Maven:

<dependency>
    <groupId>io.sentry</groupId>
    <artifactId>sentry-logback</artifactId>
    <version>1.7.27</version>
</dependency>

Using Gradle:

compile 'io.sentry:sentry-logback:1.7.27'

Using SBT:

libraryDependencies += "io.sentry" % "sentry-logback" % "1.7.27"

For other dependency managers see the central Maven repository.

Usage

The following example configures a ConsoleAppender that logs to standard out at the INFO level and a SentryAppender that logs to the GlitchTip server at the WARN level. The ConsoleAppender is only provided as an example of a non-Sentry appender that is set to a different logging threshold, like one you may already have in your project.

Example configuration using the logback.xml format:

<configuration>
    <!-- Configure the Console appender -->
    <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <!-- Configure the Sentry appender, overriding the logging threshold to the WARN level -->
    <appender name="Sentry" class="io.sentry.logback.SentryAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>WARN</level>
        </filter>
    </appender>

    <!-- Enable the Console and Sentry appenders, Console is provided as an example
 of a non-Sentry logger that is set to a different logging threshold -->
    <root level="INFO">
        <appender-ref ref="Console" />
        <appender-ref ref="Sentry" />
    </root>
</configuration>

Next, you’ll need to configure your DSN (client key) and optionally other values such as environment and release. [See the configuration page]({%- link _documentation/clients/java/config.md -%}#setting-the-dsn) for ways you can do this.