A Java library for posting log messages to Loggly, using Retrofit to interface with Loggly's REST API.
- Create a
LogglyClient
instance with your authorization token from Loggly.
final String LOGGLY_TOKEN = /* your token */;
final ILogglyClient loggly = new LogglyClient(LOGGLY_TOKEN);
- Log an event...
loggly.log("Hello world!");
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");
Logs a single event
loggly.log("hello world!");
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);
}
});
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");
Logs multiple events in bulk with a Collection<String>
Collection<String> events = Arrays.asList("event 1", "event 2");
loggly.logBulk(events);
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);
}
});
compile 'com.github.tony19:loggly-client:1.0.3'
<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.