idi527

idi527

Failing to remove info level logs from plug and phoenix

:wave:

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

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
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
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
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
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
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement