austinsmorris

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

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

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

josevalim

Creator of Elixir

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.

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

We're in Beta

About us Mission Statement