!!Currently WIP!!
This application is able to generate Graylog Extended Log Format (GELF) UDP messages (TCP version coming soon)
The package can be installed
by adding logger_gelf
to your list of dependencies in mix.exs
:
def deps do
[
{:logger_gelf, "~> 0.1.0"}
]
end
In the config.exs, add gelf_logger as a backend / add it to backends list:
config :logger,
backends: [:console, {LoggerGelf, :logger_gelf}]
You will also have to handle mandatory configuration:
config :logger, :logger_gelf,
application: "my_application",
greylog_hostname: "127.0.0.1",
greylog_hostport: 12201,
optional config:
hostname: "hostname", #defaults to :inet.gethostname/0 result
level: :warn, # defaults to lowest level (:debug)
metadata: [:id, :module, :record], # defaults to :all
metadata_formatter: {Module, :function, arity}, # custom metadata formatter - you can add any function from your module and use it for metadata formatting, skipping the option will leave metadata as it is
json_encoder: Jason, #defaults to Jason, can be overriden by any module using encode!/1 (ie. Poison)
compression: :gzip, # defaults to :gzip, :zlib or :raw are also available
Just add to deps, configure and use Logger as usual.
Credit where credit is due! This implementation was heavily inspired by: jschniper/gelf_logger.