gmile
Charlist values are not showing up in Logger metadata
Is there a reason Elixir doesn’t support charlists as values in the Logger metadata? Here’s a list of things it supports today:
I noticed this while adding opentelemetry-erlang integration to the project. opentelemetry-erlang uses values of type charlist to add span context info to log metadata, and they weren’t showing up in the logs in place where the metadata should be printed:
There are some ways to work around the problem of charlist not showing up in the logs, but I got curious if there’s a reason Elixir couldn’t support charlists ![]()
Marked As Solved
sabiwara
The current behavior is now officially documented (i.e. excluding charlists): Clarify that charlists cannot be used as logger metadata by sabiwara · Pull Request #13977 · elixir-lang/elixir · GitHub
Jose’s answer:
IIRC we ran into issue once we integrated with Erlang’s logger, so for now I would only document the current behaviour.
Also Liked
hauleth
I think the main problem there is checking whether given list is charlist or not, as that may require deep traversal. Also, if we support chartists, then should we also support IO lists? What about charlists with non-ASCII characters in them? Unfortunately, this is place where static typing would be useful, but without that, it may be computationally expensive to check given list on each log message.
LostKobrakai
This is a bit of a tricky problem given elixir uses :logger nowadays. Idealy one wouldn’t need to care if the host system is an elixir or erlang system to use a logger handler and with some configuration effort you can get there, but it’s not (yet) possible with elixir ootb.
gmile
Yes, I noticed this too and had a similar question.
I thought charlists are skipped because validating their contents is not easy / performant enough for such a critical area as logging: e.g. that lists do not contain values other than characters, or that all characters are printable, etc.
But maybe I am wrong an Elixir could indeed implement support for charlists in metadata?







