Lager is a standard logging tool for Erlang, this project crates lager formatter to output messages in GELF format and lager backend to send messages via UDP to a graylog server.
- Support for compression gzip or zlib
- Support for chunk encoded GELF messages
- Works with lager 3.x
Include this backend into your project using rebar:
{graylog_lager, ".*", {git, "https://github.com/silviucpp/graylog_lager.git", "master"}}Then you need to add a new handler in lager configuration, usually in your app.config file, for example:
{lager, [
{handlers, [
{graylog_lager_udp_backend, [
{host, "127.0.0.1"},
{port, 12201},
{level, info},
{format_config, [
{compression, disabled},
{extra_fields, [
{<<"_environment">>, <<"production">>}
]}
]}
]}
]}
]}Backend configuration parameters:
host: graylog server host, example:{host, "127.0.0.1"}port: graylog server port, example:{port, 12201}level: minimum logging level - messages below that level will be dropped. One of the above values (debug, info, notice, warning, error, critical, alert)format_config: backend-specific configuration - a proplist with:compression: one ofdisabled,gzip,zlib(atom, defaults todisabled)extra_fields: optional proplist of{name, value}, they will be sent as additional fields to graylog. The name must be a binary starting with an underscore, while the value must be any term.hostname: optional binary with the hostname. If not provided will be automatically detected.
formatter: In case you want to change the GELF formatter module. Default :{formatter, graylog_lager_gelf_formatter}chunk_size: The max size of each UPD packet: default 8154. Valid value between interval 1420 - 8154. Example:{chunk_size, 8154}inet_family: Specify the inet family. Default toinet. Supported valuesinetorinet6
Also support the following sink configs described in lager readme:
high_water_markflush_queueflush_threshold