Unicode in Erlang logs with logger

Viewed 284

I’m trying to output some Unicode into log with:

logger:debug("~ts", [<<"Тест"/utf8>>]).

and getting the following in log:

DEFAULT FORMATTER CRASHEDDEFAULT FORMATTER CRASHEDDEFAULT FORMATTER....

However, if I use ~s as a format string instead, it doesn’t crash, but outputs non-unicode version:

debug: ТеÑ<U+0081>Ñ<U+0082>

Any ideas? Can’t seem to find what am I doing wrong.

Environment

Erlang/OTP 21 [erts-10.0.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Logger config from sys.config:

{kernel, [
  {logger, [
    {handler, default, logger_std_h,
      #{level => debug,
        formatter => {logger_formatter, #{single_line => true}},
        config => #{type => {file, "log/main.log"}}}},
    {handler, errors, logger_std_h,
      #{level => error,
        formatter => {logger_formatter, #{single_line => false}},
        config => #{type => {file, "log/errors.log"}}}}
  ]},
  {logger_level, debug}
]}
1 Answers

I spent whole night tracing with someone on Erlang Slack channel and we found that it is single line formatter specifically that had a bug crashing the whole thing. It's now fixed in 21.1. After upgrading the issue's gone.

Related