GithubHelp home page GithubHelp logo

isabella232 / dropwizard-logstash-encoder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tubemogul/dropwizard-logstash-encoder

0.0 0.0 0.0 97 KB

License: Eclipse Public License 1.0

Java 100.00%

dropwizard-logstash-encoder's Introduction

dropwizard-logback-logstash-encoder

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>1.0.2</version>
</dependency>

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.

dropwizard-logstash-encoder's People

Contributors

nmonterroso avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.