Disable logging on specific route?

This StackOverflow post also provides two alternatives approaches:

Pre-Telemetry (by Wile E. Coyote):

Define a custom plug to replace Plug.Logger in endpoint.ex:

defmodule MyApp.Logger do
  def init(_opts), do: {}

  def call(%{path_info: ["ping"]} = conn, _opts) do
    Plug.Logger.call(conn, :error)
  end
  def call(conn, _opts) do
    Plug.Logger.call(conn, :info)
  end
end

Post-Telemetry (by Ilja Everilä):

Define a custom Telemetry Plug and replace the plug in endpoint.ex:

defmodule MyWeb.Plugs.Telemetry do
  @behaviour Plug

  @impl true
  def init(opts), do: Plug.Telemetry.init(opts)

  @impl true
  def call(%{path_info: ["ping"]} = conn, {start_event, stop_event, opts}) do
    Plug.Telemetry.call(conn, {start_event, stop_event, Keyword.put(opts, :log, :debug)})
  end
  def call(conn, args), do: Plug.Telemetry.call(conn, args)
end