asweet-confluent

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.

Most Liked

NobbZ

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

hauleth

Guidance Counsellor

Yes, it would be more reasonable default to use :info by default, but because of backward compatibility it needs to be :debug.

mat-hek

mat-hek

Membrane Core Team

In Membrane, we have a debug_verbose: boolean flag set via config, defaulting to false, and a corresponding debug_verbose macro. 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 :wink:

Last Post!

asweet-confluent

asweet-confluent OP

Does that configuration matter here though? Logger.start wipes it out unconditionally.

elixir --erl "-kernel logger_level warning" -e '
IO.inspect(Application.get_env(:kernel, :logger_level), label: "kernel.logger_level")
IO.inspect(Application.get_env(:logger, :level), label: "Elixir Logger level")
IO.inspect(:logger.get_primary_config()[:level], label: "actual primary level")
'
kernel.logger_level: :warning
Elixir Logger level: nil
actual primary level: :debug

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
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews