Elixir Logger integration with Erlang OTP handler

Hi, reading the Elixir logger documentation section about Erlang/OTP handlers I understand that, when Elixir Logger application bootstraps, it wipes the Erlang :logger handler configuration (whatever this is) and substitutes it with the Elixir wrapper backend that implements log processing within a single GenEvent process.

In my application I have quite a substantial amount of logs that are already written on top of the Logger, since they come from 3rd party project libraries.

At the same time my application produces some logs that cannot be lost, and others that can be, so I need control on the overload protection mechanism, or to bypass it ad interim and implement proper handlers for the two types of logs.

One way could be to keep using the Logger, but let the legacy Erlang/OTP :logger configuration in place, so I would have access to the full configurability of the OTP handlers and could implement the proper logic without the intervention of the overload protection (or deciding when it is the case for that to be or not).

Is there a way to obtain this with the Elixir Logger?

You can create your own Erlang handler that will not be restricted by the overload protection. So you can have both of the worlds working next to each other without any problems. The only thing is that you cannot use Elixir formatter with Erlang handlers as that is not yet done. Other than that just leave it as is and add new handler (to clarify, you can write Erlang handlers in Elixir).

2 Likes