dropwizard-logstash-encoder

Dropwizard logging addon for sending logs using the logstash-logback-encoder.

License

License

Categories

Categories

DropWizard Container Microservices Logstash Application Layer Libs Logging
GroupId

GroupId

io.interact
ArtifactId

ArtifactId

dropwizard-logstash-encoder
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

dropwizard-logstash-encoder
Dropwizard logging addon for sending logs using the logstash-logback-encoder.
Project URL

Project URL

https://github.com/plevie/dropwizard-logstash-encoder
Source Code Management

Source Code Management

https://github.com/plevie/dropwizard-logstash-encoder.git

Download dropwizard-logstash-encoder

How to add to project

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

Dependencies

compile (5)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-annotations jar 2.4.0
net.logstash.logback : logstash-logback-encoder jar 4.9
io.dropwizard : dropwizard-logging jar 1.1.2
com.fasterxml.jackson.core : jackson-core jar 2.4.0
com.fasterxml.jackson.core : jackson-databind jar 2.4.0

Project Modules

There are no modules declared in this project.

dropwizard-logback-logstash-encoder

DepShield Badge

Dropwizard logging addon for sending logs using the logstash-logback-encoder. This is needed because Dropwizard overwrites the default mechanism for loading logback configuration (logback.xml) in favor of its application.yml files.

Installation

Maven:

<dependency>
  <groupId>com.wikia</groupId>
  <artifactId>dropwizard-logstash-encoder</artifactId>
  <version>2.0.0</version>
</dependency>

Use version:

1.0.2 for Dropwizard <1.0

2.0.0 for Dropwizard 1.0

Usage

You must configure dropwizard to use these appenders in your application.yml file:

logging:
  appenders:
    - type: logstash-socket # LogstashSocketAppender, for LogstashTcpSocketAppender use logstash-tcp
      ...

Additional configuration keys for the appender, see logstash-logback-encoder#usage for info. All configs apply to both logstash-socket and logstash-tcp, unless otherwise noted:

  • host - string - maps to syslogHost when using logstash-socket, and remoteHost when using logstash-tcp
  • port - int
  • includeCallerInfo - boolean
  • includeContext - boolean
  • includeMdc - boolean
  • customFields - hashmap - the configuration differs from the original logstash-logback-encoder config in that this is not a raw json string (see example below)
  • fieldNames - hashmap
  • queueSize - int - only valid for logstash-tcp
  • includeCallerData - bool - only valid for logstash-tcp

Example config:

logging:
  appenders:
    - type: logstash-socket
      host: 127.0.0.1
      fieldNames:
        message: msg
        timestamp: log_date
      customFields:
        myTestField1: myTestVal
        myTestField2: 2

Then, loggers can be used the same way as if they were configured using logback.xml for logstash-logback-encoder, example (using Guava):

LoggerFactory.getLogger("myTestLogger").warn(
	appendEntries(
		new ImmutableMap.Builder<String, Object>()
			.put("some_key", 1)
			.put("some_other_key", "two")
			.build()
	),
	"warning! warning!");

License

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Versions

Version
1.0.1
1.0.0