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:
1
2
3
def deps do
  [{:gelf_logger, "~> 0.7.3"}]
end
  • Ensure logger and gelf_logger is started before your application (pre Elixir 1.4):
1
2
3
def application do
  [extra_applications: [:logger]]
end

Configuration

  • In your config.exs (or in your #{Mix.env}.exs-files):
1
2
config :logger,
  backends: [:console, {Logger.Backends.Gelf, :gelf_logger}]
1
2
3
4
5
6
7
8
9
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

Graylog-1 Graylog-3

Error

Graylog-2