Giter Site home page Giter Site logo

json_logger's Introduction

Elixir JSON Logger

JSON Logger is a logger backend that outputs elixir logs in JSON format.

This project is originally designed to make Elixir apps work with Logstash easily. It aims at providing as much information for the log is possible, so the logs can be more easily analyzed by backend services like Elasticsearch.

Issues and PRs are welcome.

Dependencies

This project requires json.

Configuration

Elixir Project

JSON Logger currently provides very few options:

  • level: The minimal level of logging. There's no default of this option. Example: level: :warn
  • output: The output of the log. Must be either :console or {:udp, host, port} or {:tcp, host, port}. Example: output: {:udp, "localhost", 514}`
  • metadata: Whatever else you want in the log. Example: metadata: "Some very important project"

Example configuration: config :logger, :json_logger, level: :info, output: {:udp, "localhost", 514}

TCP support is still experimental, please submit issues that you encounter.

In your application

You should add json_logger to your mix.exs as well. This step may not be necessary (if you know why please tell me).

defmodule MyMod.Mixfile do
  # ...
  def application do
    [applications: [:logger, :json_logger],
     mod: {MyMod, []}]
  end
  # ...
end

Adding the logger backend

You need to add this backend to your Logger, preferably put this in your Application's start/2.

Logger.add_backend Logger.Backends.JSON

If you wish to use Logstash with this library

Here is an example logstash configuration:

input {
  udp {
    port => 514
    type => "elixir_json_logging"
  }
}

filter {
  json {
    source => "message"
  }
}

output {
  stdout {
    codec => rubydebug
  }
}

Note that this configuration will probably break on your system (listening to a <1024 port). You should change the "port" to a larger value.

json_logger's People

Contributors

leeroyding avatar semmelk avatar tanguyantoine avatar timka avatar

Watchers

 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.