Proposal: Log formatting applied to all backends

29 views
Skip to first unread message

Joe ARO

unread,
Mar 21, 2019, 8:38:24 AM3/21/19
to elixir-lang-core
Hi there,

so i don't think this is possible but feel free to tell me otherwise, id love to be able to do something like this:

#config.exs
config
:logger, format:"foobar"

and have that applied to all of my logger backends currently I am having to specify the format for each of my backends like so:

#config.exs
config
:logger, :console, format: "$message\n"


#prod.exs
config :logger,
  backends: [{LoggerFileBackend, :file}]

config :logger, :file,
  path: "/var/log/component/error.log",
  format: "$message\n",
  level: :error

Apologies if this is something I have overlooked, but if not I think this would be a great feature.

Thanks,
Joe

Łukasz Niemier

unread,
Mar 30, 2019, 5:11:30 AM3/30/19
to elixir-lang-core
There are 2 problems I see:

- not all backends will support formatting, for example there is no point in having formatter in case of JSON backend, as you can provide structure that is order independent
- we should begin slow move towards deprecating `:logger` application (Elixir one) and instead promote `:logger` module (Erlang's `kernel` module) as this has more features (all syslog levels, structured logging) and will be the next standard in OTP world
Reply all
Reply to author
Forward
0 new messages