a lager formatter that produces json
when configuring lager specify lager2json
as the formatter:
{lager, [
{handlers, [
{lager_console_backend, [info, {lager2json, []}]},
{lager_file_backend, [
{file, "error.log"},
{level, error},
{formatter, lager2json},
{formatter_config, []}
]},
]}
]}.
then call lager as you normally would:
ok = lager:info("hallo world", []).
%% {"message":"hallo world","metadata":{"application":"lager2json","module":"some_module","function":"some_function","line":7,"pid":"<0.249.0>","node":"nonode@nohost"},"severity":"info","timestamp":"2016-02-29T00:38:44.954229Z"}
lager2json supports the following configuration options
{separator, Separator}
append the separator (a binary) after the json output. useful when writing to the console or file
all configuration options should be passed as a proplist
lager2json is available under either the MIT or Apache 2.0 licenses. see the
relevant LICENSE-*
file included with this application
copyright 2016 alisdair sullivan