I’m trying to suppress logging of a health check endpoint in my Phoenix Application. I managed to switch off logging in controller with use Phoenix.Controller, namespace: DsrvWeb, log: false
but I can still see messages related to health checking
20:02 $ mix phx.server
[info] Running DsrvWeb.Endpoint with Cowboy using http://0.0.0.0:4000
[info] GET /health_check
[info] Sent 200 in 11ms
How can I get rid of these messages. Of course, I want other routes to be logged as usual.
You might consider using a separate router / endpoint for this path. You can also move the Plug.Logger or whatever it is called into a separate pipeline within your router, which isn’t used for the health check route.
Unfortunately passing log: false to the scope doesn’t seem to be working to silence the info level messages that get printed. I can pass log: :debug and that changes it to debug level, but false doesn’t disable them. Phoenix 1.5.8
I actually wrote a library to solve this exact problem: unplug | Hex
The main use case for the library was to conditionally execute plugs while preserving the init_mode behavior of a plug definition. For example, if you wanted to omit the Telemetry plug from a request pipeline, you would do the following: