Logstash Logback Encoder Bundle
Dropwizard bundle that uses the Logstash Logback Encoder to provide logs ready to be consumed by Logstash and co.
Greatly inspired by the Gelf bundle for dropwizard.
Get it
0.6.2 release version available. Snapshots are available in Sonatype OSS snapshots repo
<dependency>
<groupId>net.devlab722</groupId>
<artifactId>logstash-logback-encoder-bundle</artifactId>
<version>0.6.2</version>
</dependency>
Usage
The Logstash Logback Encoder Bundle consists in a ConfiguredBundle.
To enable the LogstashLogbackEncoderBundle
and specify which part of your configuration will support the bundle configuration, simply add the following code to your Service's initialize method:
@Override
public void initialize(Bootstrap<MyServiceConfiguration> bootstrap) {
bootstrap.addBundle(new LogstashLogbackEncoderBundle<MyServiceConfiguration>() {
@Override
public LogstashLogbackEncoderConfiguration getConfiguration(MyServiceConfiguration configuration) {
return configuration.getLogstashLogbackEncoderConfiguration();
}
});
}
You also need to add a field for LogstashLogbackEncoderConfiguration
to your own Configuration class.
You can have a look at a sample project using it available at https://bitbucket.org/looztra/dropwizzardsample (see configuration file and service java file
Configuration
The LogstashLogbackEncoderConfiguration
inherits its properties from the LoggingConfiguration.FileConfiguration
and provides an additionnal property includeCallerInfo
to include or not the callerInfo (warning getting the callerInfo is an expensive operation that should not be set to true on production environments)
TODO
- provide adjustments for the upcoming 0.7.0 version of dropwizard