How do you disable logging in Ecto 3.0.7?

Since I’ve recently finished the main upgrade to Ecto 3.0 :tada: I’m now working on related updates. Since Ecto.LogEntry is soft deprecated in 3.0 (and will be fully deprecated in 3.1) I want to replace usage of it now. It seems that the way to go is to disable the built-in logging and build my own logging using the telemetry api:

  • [Ecto.Repo] The :loggers configuration is deprecated in favor of “Telemetry Events”

However, when I try to disable the built-in logging by setting my :loggers configuration to an empty list, the ecto logs are still printing out to the console when I run mix phx.server.

This is what my configuration looks like:

config :my_app, MyApp.Repo,
  loggers: []

Environment:

  • Elixir: 1.8.1
  • Erlang: 21.2
  • Ecto: 3.0.7

Edit:

After forcing a recompile of my repo I do see the following warning:

the :loggers configuration for MyApp.Repo is deprecated.
* To customize the log level, set log: :debug | :info | :warn | :error instead
* To disable logging, set log: false instead
* To hook into logging events, see the \"Telemetry Events\" section in Ecto.Repo docs

However, even adding config :my_app, MyApp.Repo, log: false I still cannot disable the built-in logging. Am I missing anything?

If log: false is not working, then that’s a bug. Please report it to the ecto_sql repo.

EDIT: although I just tried setting log: false and it worked in a local project using Ecto 3.0.

Okay, so on a closer inspection log: false is working, but I had some logging happening via a third-party on one of my repos, I had turned off that logging (via telemetry) on one of the repos, but missed another one. Sorry for the noise!

While I’m here I should explain my overall goal, which is to log binary uuids as text (so "0547838d-b356-43bb-a883-4d971f0d6fc8" instead of <<5, 71, 131, 141, 179, 86, 67, 187, 168, 131, 77, 151, 31, 13, 111, 200>>). Is that worth contributing back to Ecto? I have a commit locally that adds it to Ecto.LogEntry but since that’s being deprecated will there be a replacement that uses telemetry that is built-in to ecto? Or will that have to be provided by an external project?

Unfortunately we no longer have the information if it is UUID or a binary at the place of logging. So I am not sure about adding it to Ecto but it should be easily doable via telemetry.

Ah, I was hoping to use Ecto.UUID.cast/1, if it returned :error then the data would be logged as the existing binary, but if it returned {:ok, uuid}, then it could be logged as a UUID. But I do see how that could log something as a UUID that is not actually a UUID. Maybe I could release the code as a small ecto logging library that uses telemetry.