This library provides a simple Appender implementation to send log messages to the Scalyr logging service using logback or log4J. With this library, any Java code which uses the log4j or logback APIs can easily integrate with Scalyr.
Add the following dependency to your project's pom.xml (check Maven Central for the latest version):
<dependency>
<groupId>com.scalyr</groupId>
<artifactId>logback-log4j-appenders</artifactId>
<version>6.0.0</version>
</dependency>
NOTE: You'll also need the logback or log4j dependencies in your project's pom.xml as well (depending on which one you're using).
If you're using logback, you'll need logback-core, logback-classic, and logback-access (your version numbers may vary):
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
<version>1.1.7</version>
</dependency>
For log4j, you'll need:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
- Download the Java client library from Maven Central and add it to your project.
- Download the Appender library from Maven Central and add it to your project.
- Make sure you also have either logback or log4j jars in your project, as described in the section above.
In your logback configuration file, add a com.scalyr.logback.ScalyrAppender
.
See samples logback.groovy and logback.xml
In your log4J configuration file, add a com.scalyr.log4j.ScalyrAppender. See sample log4j.properties
Once you have log messages flowing into Scalyr, you can set up parsing rules. The easiest way to do that is to go to your parsers page, find the logback parser in the list, and click either the Ask us to create for you or Ask us to edit for you button. This will send a sample of your log data to the Scalyr staff, and we'll respond the same day with a custom-built parser.
See src/test/java/com/scalyr/logback/test/Test.java for usage examples.