GithubHelp home page GithubHelp logo

zooldk / logstash-util-formatter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from synaxon/logstash-util-formatter

0.0 2.0 0.0 167 KB

Java Util Logging formatter to encode logging events as json events which can consumed by logstash.

License: Other

logstash-util-formatter's Introduction

Java Util Logging JSON encoder for Logstash

Include as a dependency

First, add it to your project as a dependency.

Maven style:

<dependency>
  <groupId>net.logstash.logging</groupId>
  <artifactId>logstash-util-formatter</artifactId>
  <version>1.0</version>
</dependency>

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= INFO

java.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 = 1

java.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.

logstash-util-formatter's People

Contributors

datenbrille avatar mfriedenhagen avatar

Watchers

 avatar  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.