disabling log entries for specific routes

289 views
Skip to first unread message

courtne...@gmail.com

unread,
Jan 21, 2016, 6:17:52 AM1/21/16
to phoenix-talk
How would I go about disabling log entries only for specific routes? We use specific routes for status checks from the load balancers and logging those requests makes the logs full of noise. Raising the log level would mean missing out on logging the other requests.

Chris McCord

unread,
Jan 21, 2016, 8:49:16 AM1/21/16
to phoeni...@googlegroups.com
You can use the `:log` option to Phoenix.Controller:

Note, that you'll need to forgo using the default `use MyApp.Web, :controller` (or modify it to accept an option). Instead, I would just do this for the non-logged controllers:

defmodule MyController do
  use Phoenix.Controller, log: false
end


–Chris

On Jan 21, 2016, at 6:17 AM, courtne...@gmail.com wrote:

How would I go about disabling log entries only for specific routes? We use specific routes for status checks from the load balancers and logging those requests makes the logs full of noise. Raising the log level would mean missing out on logging the other requests.

--
You received this message because you are subscribed to the Google Groups "phoenix-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phoenix-talk...@googlegroups.com.
To post to this group, send email to phoeni...@googlegroups.com.
Visit this group at https://groups.google.com/group/phoenix-talk.
To view this discussion on the web visit https://groups.google.com/d/msgid/phoenix-talk/d52b61d0-6aff-4226-a6f1-47a667afeef7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Courtney

unread,
Jan 22, 2016, 3:34:03 AM1/22/16
to phoenix-talk
Actually looks like it's not a phoenix thing really. That doesn't quite do what I was hoping.

Really it's this: https://github.com/elixir-lang/plug/blob/master/lib/plug/logger.ex#L33-L41 I wanted to disable selectively by routes which means I'd need to have a different pipeline for unlogged routes.

If only it were that easy.

Thanks the info though, forced me to dig around a bit in the source to figure out why it wasn't working as I expected which is always a good thing I suppose.
Reply all
Reply to author
Forward
0 new messages