[Proposal] Add JSON structured logging backend to Logger

95 views
Skip to first unread message

Blake Kostner

unread,
Dec 8, 2020, 10:27:37 PM12/8/20
to elixir-lang-core
Considered the growth of structured logging, it would be really nice if elixir included a JSON Logger backend by default. This would be very basic and not include any weird paths or third party service specific fields, but it would wrap up multi line outputs (like stack traces) to a single line for easier parsing.

I would also note that this backend would have to take the `json_library` option (similar to other packages) in the configuration to avoid bringing all of that stuff to core.

José Valim

unread,
Dec 9, 2020, 1:04:42 AM12/9/20
to elixir-l...@googlegroups.com
Hi Blake, Logger already provides a custom formatter and you can replace the formatter to emit JSON instead.

We don't intend to include a JSON specific formatter by default because this is something that can be trivially done as a library (and there is no benefit doing it from core itself compared to a lib).

On Wed, Dec 9, 2020 at 4:27 AM Blake Kostner <btko...@gmail.com> wrote:
Considered the growth of structured logging, it would be really nice if elixir included a JSON Logger backend by default. This would be very basic and not include any weird paths or third party service specific fields, but it would wrap up multi line outputs (like stack traces) to a single line for easier parsing.

I would also note that this backend would have to take the `json_library` option (similar to other packages) in the configuration to avoid bringing all of that stuff to core.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/38c7eba9-9b58-47c4-be2e-061e9991f8adn%40googlegroups.com.

Austin Ziegler

unread,
Dec 9, 2020, 1:13:25 PM12/9/20
to elixir-l...@googlegroups.com
This is something that can/should be done in a library, but there’s a number of incomplete, outdated, or half-finished JSON formatters on hex.pm and there is probably a good opportunity for an opinionated `Nimble` library…

-a



--

luk...@niemier.pl

unread,
Feb 23, 2021, 7:22:14 AM2/23/21
to elixir-lang-core
Well, while there is no built-in JSON formatter (and probably will not be unless EEP 18 will land) with new Erlang handlers it is quite easy to provide such formatter externally. And doing such in a way that still requires configuration and bringing external libraries to the application is IMHO just pointless, as you can just bring library that will provide formatter module.

Ulisses Almeida

unread,
Feb 25, 2021, 2:49:52 PM2/25/21
to elixir-lang-core
I felt that in my skin on my previous work. We had many different Elixir apps, each one used a different library, each library was missing some feature or had some bug, each library was forked to fill the missing gap, every fork wasn't great.
Reply all
Reply to author
Forward
0 new messages