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.

Showing Posts 1 to 10

hauleth

hauleth

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

jhogberg

jhogberg

Erlang Core Team

The way to structurally prevent this from happening is having :debug as a default: you noticed it, didn’t you? :smiley:

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.

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:

asweet-confluent

asweet-confluent OP

What’s the bar for breaking compatibility? There’s some precedent for doing so when it prevents confusion:

feat(logger): return primary level as is, without conversion
This is breaking change, but inevitable to not confuse users.

Changing the default log level to something safer for production doesn’t seem like a huge stretch by comparison.

It would be nice to have a deprecation path. Can Logger reliably distinguish between an explicitly configured log level and falling back to its implicit :debug default? If so, it seems like reliance on the implicit default could first be deprecated, giving users who actually want :debug a chance to configure it explicitly.

Another interesting data point: Phoenix’s default production configuration sets the level to :info. If Phoenix is as widely used as I think it is, I suspect this masks the problem since most people never have to deal with the consequences of Logger’s defaults.

hauleth

hauleth

Yeah, I know, that is my work.

I 100% agree with you that default of :debug is wrong and should be changed, ideally to match Erlang’s :notice, as it would make a lot of stuff much easier.

Unfortunately - no. If that would be possible then I would propose that in the first place, but there is no way to detect that.

I believe that the default configuration of logger should match the production environment, not dev. Dev environment is form of special environment, and accidental leakage of private data (which may be logged in debug logs) is bigger issue IMHO.

mudasobwa

mudasobwa

Creator of Cure

For me and my libraries the bar is never. Breaking backward compatibility is a clear sign of code authors don’t give a dime about their users.

asweet-confluent

asweet-confluent OP

Couldn’t Logger.App.start/2 detect this by checking both Application.fetch_env(:logger, :level) and the preexisting :logger primary level?

If no Elixir level is configured and OTP is still at its default :notice, then Logger is about to introduce the implicit :debug. What case would make that detection incorrect?

hauleth

hauleth

It will not work when someone sets logger level using kernel application option. That option is not easily useable in development, but in production deployments it is more common.

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
— All posts loaded —

Where Next? Top

Trending in Questions Top

Hellowman
Hello everyone! I am new to coding with Elixir/Erlang. And i am looking for some utilities for fuzzing testing like AFL++. Does anyone ...
New
yarrichar
I’m very new to Elixir, so sorry if this is a silly question: I am wondering what happens to the mailbox of a process when the machine i...
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
mandar1045
I load tested a plain Phoenix chat app backed by Postgres with 100 million messages in it, everything on default settings, to see what br...
New
Fl4m3Ph03n1x
Background When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error: * assembling mark...
New
rlipscombe
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
saleyn
Is there a way to import record definitions in the iex shell for pretty printing (similar to the rr command in the erl shell)? This woul...
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...
261 13183 112
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews