When/how is Logger app started?

:logger and Logger are separate beasts. :logger is part of Erlang’s :kernel application and cannot be directly configured via config.exs file (as it is already loaded and started when config.exs is parsed) and :logger application is part of Elixir’s distribution. From now I will call them :logger module and logger application respectively.

The current flow is as follows (simplified):

  • kernel application is started (so :logger module is configured)
  • config.exs file is loaded (so it cannot configure :logger module)
  • logger application is started
  • logger application configures :logger module to use Elixir’s configuration

So if you want to change log level from the config.exs then you need to use logger application:

config :logger, level: :warning

This should set :logger.get_config().primary.level to :warning so messages would be filtered by :logger module.

Yes, this is a little bit confusing, because of the compatibility reasons in Elixir, but I hope to improve that over a time in the future.

3 Likes