idi527

idi527

Failing to remove info level logs from plug and phoenix

: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

Most Liked

idi527

idi527

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

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement