Skip to content

linakis/loggly-client

 
 

Repository files navigation

loggly-client

v1.0.3

A Java library for posting log messages to Loggly, using Retrofit to interface with Loggly's REST API.

Quickstart

  1. Create a LogglyClient instance with your authorization token from Loggly.
final String LOGGLY_TOKEN = /* your token */;
final ILogglyClient loggly = new LogglyClient(LOGGLY_TOKEN);
  1. Log an event...
loggly.log("Hello world!");

API

setTags(String... tags)

Sets the Loggly tag(s) with variable arity strings (or with a CSV) to be applied to all subsequent log calls. Specify empty string to clear all tags.

loggly.setTags("foo", "bar");
// or equivalently:
loggly.setTags("foo,bar");

log(String message)

Logs a single event

loggly.log("hello world!");

log(String message, Callback callback)

Logs an event asynchronously

loggly.log("hello",
        new LogglyClient.Callback() {
            @Override
            public void success() {
                System.out.println("ok");
            }

            @Override
            public void failure(String error) {
                System.err.println("error: " + error);
            }
        });

logBulk(String... messages)

Note: In order to preserve event boundaries in a bulk upload, loggly-client replaces new-line characters ('\n') with carriage-returns ('\r'), which are subsequently stripped by Loggly.

Logs multiple events in bulk with variable arity strings

loggly.logBulk("event 1", "event 2");

logBulk(Collection<String> messages)

Logs multiple events in bulk with a Collection<String>

Collection<String> events = Arrays.asList("event 1", "event 2");
loggly.logBulk(events);

logBulk(Collection<String> messages, Callback callback)

Logs multiple events asynchronously in bulk with a Collection<String>

Collection<String> events = Arrays.asList("event 1", "event 2");
loggly.logBulk(events,
        new LogglyClient.Callback() {
            @Override
            public void success() {
                System.out.println("ok");
            }

            @Override
            public void failure(String error) {
                System.err.println("error: " + error);
            }
        });

Download

loggly-client-1.0.3.jar

Gradle

compile 'com.github.tony19:loggly-client:1.0.3'

Maven

<dependency>
  <groupId>com.github.tony19</groupId>
  <artifactId>loggly-client</artifactId>
  <version>1.0.3</version>
</dependency>

Snapshots of the development version are available in Sonatype's snapshots repository.

Packages

No packages published

Languages

  • Java 100.0%