Hello,
I’m adding support for Elixir 1.11 to a package I maintain and I’m having some issues with the logger configuration. This might be related to this forum thread or issue 6016 on the Elixir GitHub repo.
Until Elixir 1.10, I’ve been able to set the log level in config/test.exs
with:
config :logger, level: :error
Now, with Elixir 1.11 this seems to not have any effect and my test output is full of debug lines, e.g. from Ecto.
That line still works in dev (e.g. if I set it in config/config.exs
and then run iex -S mix
). I’ve also tried with both the old use Mix.Config
and the new import Config
, with the same results. (For the avoidance of doubt: yes, the test config file is being imported.)
I find it interesting that by the time test/test_helper.exs
is executed, I can verify that this configuration has been set:
Logger.level() # :debug
:logger.get_primary_config()[:level] # :debug
Application.get_env(:logger, :level) # :error
Which makes me think that something is preventing Elixir from configuring the Erlang logger in the tests. In dev, the integration works normally and those values appear to be in sync.
The only way I’ve found to make it work is to configure the logger directly in config/test.exs
:
- config :logger, level: :error
+ Logger.configure(level: :error)
This feels wrong though, and I can’t help but wonder if there is something obvious that I’ve missed, and an easier way to solve the problem. This kind of change in behaviour between 1.10 and 1.11 seems the kind of thing that someone else must have stumbled upon before.