derek-zhou
How to suppress NoRouteError in Phoenix 1.7.2 and Bandit?
Ever since I upgrade to Phoenix 1.7.2 and Bandit, my log file is polluted with junk such as:
14:38:32.113 request_id=F1pur8zunbgsR1kAAoIR [error] GenServer #PID<0.9364.14> terminating
** (Phoenix.Router.NoRouteError) no route found for GET /sitemap.xml (RoastidiousWeb.Router)
...
I don’t want to make a catch-all route just to do 404, and I don’t remember seeing this back when I was using cowboy. Is there a way to config the stack to suppress logging for NoRouteError only?
Marked As Solved
mtrudel
Also Liked
mtrudel
I got most of the way through exactly what you suggested, but then realized that Phoenix isn’t actually supposed to be raising NoRouteError errors externally (see phoenix/lib/phoenix/endpoint/render_errors.ex at main · phoenixframework/phoenix · GitHub)
This looks like a loooooooongstanding error in Phoenix that’s been silently canceled out by Cowboy’s silent error handling.
I’m working up the last bits of a PR for Phoenix to correct this, at which point we’ll end up with a better end result:
- Phoenix renders NoRouteError errors and doesn’t raise them further
- Phoenix renders all other errors and raises them further
- Bandit logs loudly on all errors it receives
- Cowboy doesn’t log errors it receives
This will end up with Bandit continuing to log all non NoRouteError errors loudly, which is what we want in general. NoRouteErrors will be silenced within Phoenix, which is really the correct place to be expressing this logic.
Expect Phoenix PR by end of day.
mtrudel
Yep, I agree this is sub-par. Fix is coming to Bandit in the next few hours to quell this logging.
mtrudel
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









