When to use Logger or :error_logger

Hi,

A simple question today. Is there any reason why some Elixir libraries like GenStage directly use :error_logger.error_msg instead of Logger.error?

What are the general guidelines on what to use, in the context of writing a library vs. writing an application?

Thank you

1 Like

GenStage used :error_logger so it looks like GenServer and other behaviours written in Erlang/OTP. Unless you are writing a low-level abstraction that should behave like a GenServer, then always use Logger. Even :error_logger itself is deprecated and we will have to update GenStage source at some point.

4 Likes

Ok, thank you @josevalim for the clarification. If I were to write a low-level abstraction, what should I use then. Have you already decided what you will use for GenStage? Maybe the “new” Erlang :logger?

1 Like

Yup, it would be the new Erlang :logger.

2 Likes