Is it possible to get notice level logs in an Elixir app?

So, my place of employment has some budgetary concerns and due to that, we don’t record historical info level logs, only warning and error ones. I’m developing a feature that would hugely benefit from some logs for debugging but those logs would be more like breadcrumbs and not warnings or errors. After talking to the person responsible for devops he told me they would start recording notice level logs, since that would work for my feature and still exclude a lot of info logs that might not be necessary.

I was pretty happy with this and switched all the relevant logs to notice level, but somehow they weren’t getting picked up by gcc (which is what we use to see logs). After some investigation we found out that it was because the logs were getting translated to info level.

At the moment the Logger docs have this to say about notice level logs:

  • level is one of :debug, :info, :warn, or :error, as previously described (for compatibility with pre 1.10 backends the :notice will be translated to :info and all messages above :error will be translated to :error)

I then found this old topic and I confess that most of the discussion went over my head, but I saw it mentioned that the implementation of :logger was actually s bit newer than elixir’s Logger and from that I got the impression that if perhaps I used :logger directly I could get actual notice logs. Turns out that that is not true, they still get translated to info.

So my question is, is there any way to actually get notice level logs in an Elixir app?

1 Like

That should not be true, as the translation happens just before sending them to backends. So if you use Erlang’s handlers, then you should be able to read true level without issues.

3 Likes

This appears to be from the docs for custom backends in Logger 1.13.

That mechanism was replaced in 1.15, with new machinery that supports all the Erlang levels.

1 Like