Last active
August 29, 2015 14:26
-
-
Save russgray/120ed9c4972df6526353 to your computer and use it in GitHub Desktop.
Simple dropwizard integration for https://github.com/tapstream/rollbar-logback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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