A logger backend that will generate Graylog Extended Log Format messages.

Taking advatage of Elixir logger API, gelf_logger

  • Add gelf_logger to your list of dependencies in mix.exs:
def deps do
  [{:gelf_logger, "~> 0.7.3"}]
end
  • Ensure logger and gelf_logger is started before your application (pre Elixir 1.4):
def application do
  [extra_applications: [:logger]]
end

Configuration

  • In your config.exs (or in your #{Mix.env}.exs-files):
config :logger,
  backends: [:console, {Logger.Backends.Gelf, :gelf_logger}]

  config :logger, :gelf_logger,
      port: 2202,
      application: "aadya",
      compression: :raw,
      metadata: [:request_id, :function, :module, :file, :line],
      host: "<server_host>.logs.ovh.com",
      tags: [
         "X-OVH-TOKEN": "xxxxxxxx-x-x-x-xxx-xxx"
      ]

Output

Success

Error


Join Our Telegram Channel

Blackoders
  Telegram
  Channel

Check out the GitHub repository on Killer Elixir Tips

Blackoders
  Telegram
  Channel Glad if you can contribute with a

🎉 Happy Coding :)


author image
WRITTEN BY
Anwesh