idi527

idi527

:waving_hand:

I’ve added

config :logger,
  compile_time_purge_matching: [
    [application: :phoenix, level_lower_than: :warn],
    [application: :plug, level_lower_than: :warn]
  ]

to my config (dev.exs) and recompiled phoenix and plug with mix deps.compile plug phoenix --force (using dev env) but the info level logs still show up (in dev env).

The global logger log level is set to :debug.

What have I done wrong?

elixir -v

Erlang/OTP 22 [erts-10.4.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.9.0 (compiled with Erlang/OTP 22)

Not specifying level_lower_than seems to work as

config :logger,
  compile_time_purge_matching: [
    [application: :phoenix],
    [application: :plug]
  ]

removes all logs as seen from the compilation warnings

==> plug
Compiling 1 file (.erl)
Compiling 39 files (.ex)
warning: variable "log" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/plug/session/cookie.ex:131: Plug.Session.COOKIE.decode/3

warning: variable "log" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/plug/session/cookie.ex:158: Plug.Session.COOKIE.decode/3

warning: variable "level" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/plug/logger.ex:26: Plug.Logger.call/2

warning: System.stacktrace/0 outside of rescue/catch clauses is deprecated. If you want to support only Elixir v1.7+, you must access __STACKTRACE__ inside a rescue/catch. If you want to support earlier Elixir versions, move System.stacktrace/0 inside a rescue/catch
  lib/plug/conn/wrapper_error.ex:23

Generated plug app
==> phoenix
Compiling 67 files (.ex)
warning: variable "level" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/phoenix/logger.ex:107: Phoenix.Logger.phoenix_endpoint_start/4

warning: variable "level" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/phoenix/logger.ex:116: Phoenix.Logger.phoenix_endpoint_stop/4

warning: variable "level" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/phoenix/logger.ex:132: Phoenix.Logger.phoenix_error_rendered/4

warning: variable "level" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/phoenix/logger.ex:154: Phoenix.Logger.phoenix_router_dispatch_start/4

warning: variable "level" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/phoenix/logger.ex:182: Phoenix.Logger.phoenix_socket_connected/4

warning: variable "level" is unused (if the variable is not meant to be used, prefix it with an underscore)
  lib/phoenix/logger.ex:257: Phoenix.Logger.channel_log/3

Generated phoenix app

Showing Posts 1 to 3

idi527

idi527 OP

Seems like since level is settable for phoenix logger at runtime it’s not purgeable with this option.

My goal was to remove GET / ... Sent in ... logs in :info level and it was possible by setting :log option to :debug for Plug.Logger.

plug Plug.Logger, log: :debug

# and in config
config :logger, level: :info
idi527

idi527 OP

Actually that didn’t work, the logs still appear but now for phoenix sockets and controllers.

[info] CONNECTED TO Phoenix.LiveView.Socket in 195µs
  Transport: :websocket
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Connect Info: %{}
  Parameters: %{"vsn" => "2.0.0"}

Line: 183
Function: "phoenix_socket_connected/4"
Module: Phoenix.Logger
Application: :phoenix
File: "lib/phoenix/logger.ex"
[info] Converted error Phoenix.Router.NoRouteError to 404 response

Line: 133
Function: "phoenix_error_rendered/4"
Module: Phoenix.Logger
Application: :phoenix
File: "lib/phoenix/logger.ex"

even though I have

use Phoenix.Controller, log: false

set in app_web.ex and

  socket "/live", Phoenix.LiveView.Socket, log: false

  socket "/socket", App.Web.UserSocket,
    websocket: true,
    longpoll: false,
    log: false

set in endpoint.ex.

Phoenix version 1.4.9


Seems like the log level option for "phoenix_error_rendered/4" comes from a module attribute, so my changes to config are unlike to change anything … Do I need to recompile the :phoenix dependency? Seems like I need to set log: false in for endpoint’s render_errors option. I wonder if I’m missing some obvious way to turn off all logs in phoenix. Or rather make them at :debug level.


Very strange, the function that logs "phoenix_error_rendered/4" doesn’t receive the log level (according to the gist below), but that would mean that it should use :debug level but uses :info instead as I see it logged.

https://gist.github.com/syfgkjasdkn/668072702caeb965bae3c8e895abddb5


Trace for socket connect log:

# Phoenix.Logger.phoenix_socket_connected(
[:phoenix, :socket_connected],
%{duration: 189593},
%{connect_info: %{}, endpoint: Web.Endpoint, log: :info, params: %{"vsn" => "2.0.0"}, result: :ok, serializer: Phoenix.Socket.V2.JSONSerializer, transport: :websocket, user_socket: Phoenix.LiveView.Socket, vsn: "2.0.0"}, 
:ok)

Log level is :info, even though it’s set to false in the endpoint …


Tried recompiling from scratch, still socket_connected gets logged. Giving up for today :slight_smile: Would need to find an easier way to do the logging, since in phoenix logs are neither purgeable at compile-time, nor settable at runtime … unless I’m holding it wrong.

grigorius

grigorius

I encountered the same issue with a plug app - can not purge Plug.Logger info logs even after running mix deps.compile --force

Still see this:
16:31:58.961 [info] Sent 200 in 1m

Config:

config :logger,
  compile_time_purge_matching: [
    [level_lower_than: :notice]
  ]

Version:

Erlang/OTP 28 [erts-16.1]
Interactive Elixir (1.19.1)
— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews