Logging Elixir application on Graylog on OVH or similar cloud providers
Published in
1 min readApr 13, 2018
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 inmix.exs
:
def deps do
[{:gelf_logger, "~> 0.7.3"}]
end
- Ensure
logger
andgelf_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
Blog is posted on http://blog.ahamtech.in/aadya/2018/03/11/Logging-Aadya-on-Graylog/