asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is present.
In Logger.App, the default ultimately comes from this line:
Application.get_env(:logger, :level, :debug)
Would something like :info or even :warning be a more reasonable default?
I bring this up because I ran into an issue where someone changed our log level from :info to :warn and it resulted in log spam. While Logger is pretty good about changing :warn into :warning under the hood, we have some code that goes through :logger.set_handler_config, which doesn’t have that check and just returns an error. If you don’t catch that, you’re left on :debug.
I’m thinking about how to prevent this situation in the future, and while I can add error handling around every call into :logger, I don’t see a good way to structurally prevent this sort of thing from happening again - it seems like it just comes down to “remember to do it right”, which makes me think this is a footgun in Logger rather than something I should be solving.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Most Liked- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
NobbZ
I hate logging systems that hide messages by default from me.
When initially developing I want to see all the messages without having to mind about configuration.
hauleth
Yes, it would be more reasonable default to use
:infoby default, but because of backward compatibility it needs to be:debug.mat-hek
In Membrane, we have a
debug_verbose: booleanflag set via config, defaulting tofalse, and a correspondingdebug_verbosemacro. It’s intended for logs that are only useful for debugging the library itself, so we decided to hide them from the user by default.For the regular debugs, I’d prefer if they were also disabled by default, as they’re intended for, well, debugging
Last Post!
asweet-confluent
Does that configuration matter here though?
Logger.startwipes it out unconditionally.