Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SYNAXON/logstash-util-formatter
Java Util Logging formatter to encode logging events as json events which can consumed by logstash.
https://github.com/SYNAXON/logstash-util-formatter
Last synced: 4 days ago
JSON representation
Java Util Logging formatter to encode logging events as json events which can consumed by logstash.
- Host: GitHub
- URL: https://github.com/SYNAXON/logstash-util-formatter
- Owner: SYNAXON
- License: other
- Created: 2013-04-16T10:02:10.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-01-24T17:23:05.000Z (almost 7 years ago)
- Last Synced: 2024-08-01T13:33:44.234Z (3 months ago)
- Language: Java
- Size: 205 KB
- Stars: 22
- Watchers: 5
- Forks: 23
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ccamel - SYNAXON/logstash-util-formatter - Java Util Logging formatter to encode logging events as json events which can consumed by logstash. (Java)
README
# Java Util Logging JSON encoder for Logstash
## Include as a dependency
First, add it to your project as a dependency.
Maven style:
```xml
net.logstash.logging
logstash-util-formatter
1.0```
Use it in your `logging.properties` like this:
```
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.formatter=net.logstash.logging.formatter.LogstashUtilFormatter```
Use it in your logstash configuration like this:
```
input {
file {
type => "your-log-type"
path => "/some/path/to/your/file.log"
format => "json_event"
}
}
```## Example usage in Jenkins on Debian
* Create a directory in `JENKINS_HOME`: `mkdir /var/lib/jenkins/lib`
* Copy the shaded jar to this directory.
* Create a `logging.properties` in `/var/lib/jenkins/lib`:```
handlers= java.util.logging.ConsoleHandler,java.util.logging.FileHandler
.level= INFOjava.util.logging.FileHandler.level = INFO
java.util.logging.FileHandler.formatter = net.logstash.logging.formatter.LogstashUtilFormatter
java.util.logging.FileHandler.pattern = /var/log/jenkins/logstash.log
java.util.logging.FileHandler.limit = 5000000
java.util.logging.FileHandler.count = 1java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
```
* Extend `JAVA_ARGS` in `/etc/default/jenkins`:```
JAVA_ARGS="$JAVA_ARGS -Djava.endorsed.dirs=$JENKINS_HOME/lib -Djava.util.logging.config.file=$JENKINS_HOME/lib/logging.properties"
JAVA_ARGS="$JAVA_ARGS -Dnet.logstash.logging.formatter.LogstashUtilFormatter.tags=master,mailer"
```* Use it in your logstash configuration like this:
```
input {
file {
type => "jenkins-server"
path => "/var/log/jenkins/logstash.log"
format => "json_event"
}
}
```
* By setting the system propery `net.logstash.logging.formatter.LogstashUtilFormatter.tags` you may easily add tags,
which let you differentiate between multiple instances running on the same host.