austinsmorris
JSON Logger backend for elixir 1.10
Does anybody know of a JSON backend for Logger that works with the updates in elixir 1.10? I had been using logger_json but that broke pretty bad with the erlang/otp logger integration introduced in elixir 1.10.0.
Thanks@
Most Liked
hauleth
How did it break? Do you have link? Maybe I will be able to help.
In general the plan is to shift away from Elixir’s Logger formatters and backends and instead make use of Erlang’s logger.
So the “simplest” way for “modern” handling would be to (unfortunately) write custom formatter (that implements one function format/2) and then use it together with whatever backend you like.
EDIT:
I will try to provide an example later.
fuelen
we use ink at work.
Test with Elixir 1.10:
ex(4)> Logger.add_backend(Ink)
{:ok, #PID<0.24432.0>}
iex(5)> Logger.remove_backend(:console)
:ok
iex(6)> require Logger
Logger
iex(7)> Logger.info("test", %{current_user_id: "qweqe"})
{"current_user_id":"qweqe","domain":["elixir"],"erlang_pid":"#PID<0.24423.0>","file":"iex","gl":"#PID<0.65.0>","level":"info","message":"test","time":1580851293206227,"timestamp":"2020-02-04T23:21:33.206Z"}
:ok
josevalim
Luckily the fix should be easy: just remove the fields with process information from the metadata. It probably already keeps a list of fields to remove, we just need to update it.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









