Logstash Logback Encoder bundle for Dropwizard

Addon bundle for Dropwizard to support logging in json format that can be consumed as-is by tools like Logstash or Graylog2

License

License

Categories

Categories

Net Logback Application Layer Libs Logging Logstash
GroupId

GroupId

net.devlab722
ArtifactId

ArtifactId

logstash-logback-encoder-bundle
Last Version

Last Version

0.6.2
Release Date

Release Date

Type

Type

jar
Description

Description

Logstash Logback Encoder bundle for Dropwizard
Addon bundle for Dropwizard to support logging in json format that can be consumed as-is by tools like Logstash or Graylog2
Project URL

Project URL

https://github.com/looztra/logstash-logback-encoder-bundle
Source Code Management

Source Code Management

https://github.com/looztra/logstash-logback-encoder-bundle

Download logstash-logback-encoder-bundle

How to add to project

<!-- https://jarcasting.com/artifacts/net.devlab722/logstash-logback-encoder-bundle/ -->
<dependency>
    <groupId>net.devlab722</groupId>
    <artifactId>logstash-logback-encoder-bundle</artifactId>
    <version>0.6.2</version>
</dependency>
// https://jarcasting.com/artifacts/net.devlab722/logstash-logback-encoder-bundle/
implementation 'net.devlab722:logstash-logback-encoder-bundle:0.6.2'
// https://jarcasting.com/artifacts/net.devlab722/logstash-logback-encoder-bundle/
implementation ("net.devlab722:logstash-logback-encoder-bundle:0.6.2")
'net.devlab722:logstash-logback-encoder-bundle:jar:0.6.2'
<dependency org="net.devlab722" name="logstash-logback-encoder-bundle" rev="0.6.2">
  <artifact name="logstash-logback-encoder-bundle" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.devlab722', module='logstash-logback-encoder-bundle', version='0.6.2')
)
libraryDependencies += "net.devlab722" % "logstash-logback-encoder-bundle" % "0.6.2"
[net.devlab722/logstash-logback-encoder-bundle "0.6.2"]

Dependencies

compile (3)

Group / Artifact Type Version
com.yammer.dropwizard : dropwizard-core jar 0.6.2
net.logstash.logback : logstash-logback-encoder jar 1.3
org.assertj : assertj-core jar 1.5.0

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 0.12.0

test (1)

Group / Artifact Type Version
org.testng : testng jar 6.8.5

Project Modules

There are no modules declared in this project.

Logstash Logback Encoder Bundle

Build Status

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

Versions

Version
0.6.2