https://github.com/Wikia/dropwizard-logstash-encoder
https://github.com/Wikia/dropwizard-logstash-encoder
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Wikia/dropwizard-logstash-encoder
- Owner: Wikia
- License: epl-1.0
- Archived: true
- Created: 2015-01-09T20:30:24.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-04-26T14:22:15.000Z (about 8 years ago)
- Last Synced: 2025-07-22T20:52:40.280Z (11 months ago)
- Language: Java
- Size: 25.4 KB
- Stars: 18
- Watchers: 94
- Forks: 28
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-dropwizard - dropwizard-logstash-encoder - Dropwizard logging addon for sending logs using the logstash-logback-encoder (Open Source / Logging)
README
# dropwizard-logback-logstash-encoder
[Dropwizard](http://dropwizard.io/) logging addon for sending logs using the [logstash-logback-encoder](https://github.com/logstash/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:
```xml
com.wikia
dropwizard-logstash-encoder
2.0.0
```
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:
```yml
logging:
appenders:
- type: logstash-socket # LogstashSocketAppender, for LogstashTcpSocketAppender use logstash-tcp
...
```
Additional configuration keys for the appender, see [logstash-logback-encoder#usage](https://github.com/logstash/logstash-logback-encoder/blob/master/README.md#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:
```yaml
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):
```java
LoggerFactory.getLogger("myTestLogger").warn(
appendEntries(
new ImmutableMap.Builder()
.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.