DOCUMENTATION

Appender for Logback

You can use the logify-alert-logback library to send Logback log messages to Logify Alert.

Add the Library to Your Application

  1. Add the logify-alert-logback library to your application.

    In the pom.xml file, do the following:

    1. In the dependencies section, declare the logify-alert-logback library dependency:

      <dependency>
        <groupId>com.devexpress.logify</groupId>
        <artifactId>logify-alert-logback</artifactId>
        <version>1.0.2</version>
      </dependency>
      

    2. In the repositories section, declare the Logify Alert's maven repository:

      <repository>
        <id>any-name-or-id</id>
        <url>https://github.com/DevExpress/Logify.Alert.Clients/raw/maven </url>
      </repository>
      

    In the build.gradle file, do the following:

    1. In the dependencies section, declare the logify-alert-log4j library dependency:

      compile "com.devexpress.logify:logify-alert-logback:1.0.2"

    2. In the repositories section, declare the Logify Alert's maven repository:

      maven {
          url "https://github.com/DevExpress/Logify.Alert.Clients/raw/maven"
      }
      

  2. Synchronize your project.

Set Up the Logify Alert's Java Client

Configure the Logify Alert client in the logify.properties file or in your application's code.

# required
apiKey=YOUR_API_KEY

# optional
appName=YOUR_APP_NAME
appVersion=YOUR_APP_VERSION
userId=YOUR_USER_ID
customData=NAME_1:VALUE_1,NAME_2:VALUE_2,NAME_3:VALUE_3
tags=TAG_1:VALUE_1,TAG_2:VALUE_2

import com.devexpress.logify.alert.java.LogifyAlert;

LogifyAlert client = LogifyAlert.getInstance();

// required
client.setApiKey("YOUR_API_KEY");

// optional
client.setAppName("YOUR_APP_NAME");
client.setAppVersion("YOUR_APP_VERSION");
client.setUserId("YOUR_USER_ID");
client.addCustomData("NAME_1", "VALUE_1");
client.addTag("TAG_1", "VALUE_1");

Register an Appender

Register the LogifyAlertAppender as a standard Logback appender in the logback.xml configuration file:

<configuration>
    <appender name="LOGIFYALERT" class="com.devexpress.logify.alert.logback.LogifyAlertAppender" />

    <root level="debug">
        <appender-ref ref="LOGIFYALERT" />
    </root>
</configuration>

Now a new report is generated and sent to Logify Alert each time your application calls the error Logback method with the ILoggingEvent.getThrowableProxy() parameter. For example:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main {
    private final static Logger logger = LoggerFactory.getLogger(Main.class);

    public static void main(String[] args) {
        logger.error("logback test message", new Throwable("logback test error"));
    }
}

Terms of use Copyright © 2016-2019 Developer Express Inc.