Logger changes in Elixir 1.15

By all accounts the documentation says that logging in Elixir is aligning more with Erlang, but the existing approach is soft deprecated.

I haven’t found this to be the case and instead have encountered a breaking change.

Previously, this code was ok:

config :logger,
  format: "$time $metadata[$level] $message\n",
  metadata: [:request_id, :span_id, :trace_id],
  backends: [LoggerJSON, Sentry.LoggerBackend]

But now it fails because metadata is not supported as an option, and the application does not compile.

The upgrade docs for 1.15 say that things are deprecated, not broken, so I expected that this would continue to compile but with a warning instead.

It’s not clear what the compatible migration path is between all of this, am I missing something?


If it is a breaking change, it is a bug. Can you please do a report with a mechanism to reproduce it? Thank you!

I had the same issue when upgrading to 1.15. The app I upgraded originally was built with Phoenix 1.4 and the generator at that time included metadata options in the logger configuration with :request_id, and it had carried through every upgrade until this one.

It was especially nefarious, as it was a hard Erlang beam crash that didn’t indicate what exactly had failed other than Logger. I managed to figure it out after looking at phoenixdiff and noticing that option was removed from the generated config in later versions.

As an aside, I never did look into why this option was used in the first place, and removing it didn’t seem to affect anything I did with Phoenix’s request_id in code. I can’t say the same for your additional :span_id and :trace_id atoms as I haven’t seen them used before.

1 Like