Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple dropwizard integration for https://github.com/tapstream/rollbar-logback
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.Layout;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.tapstream.rollbar.RollbarAppender;
import io.dropwizard.logging.AbstractAppenderFactory;
import javax.validation.constraints.NotNull;
@JsonTypeName("rollbar")
public class RollbarAppenderFactory extends AbstractAppenderFactory {
@NotNull
private String environment = "development";
private String apiKey;
@JsonProperty
public String getEnvironment() {
return environment;
}
@JsonProperty
public void setEnvironment(String environment) {
this.environment = environment;
}
@JsonProperty
public String getApiKey() {
return apiKey;
}
@JsonProperty
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
@Override
public Appender<ILoggingEvent> build(LoggerContext context, String applicationName, Layout<ILoggingEvent> layout) {
final RollbarAppender appender = new RollbarAppender();
appender.setApiKey(apiKey);
appender.setEnvironment(environment);
appender.setContext(context);
appender.start();
return wrapAsync(appender);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.