Logger metadata leak

Hello guys! I don’t understand how I can configure Elixir logger metadata which comes from Erlang/OTP internal entities. Let’s say I have config

  config :logger,
    level: :info,
    backends: [{LogstashJson.Console, :logstash_json}],
    handle_otp_reports: true,
    handle_sasl_reports: false,
    logstash_json: [
      metadata: [
        :application,
        :module,
        :file,
        :function,
        :level,
        :line
      ]
    ]

where I explicitly define which metadata I want to be presented.
But sometimes when something like Task #PID<0.17871.20> started from TheBestApp terminating ** (MatchError) happens then somehow crash_reason metadata leaks to my JSON logs. Which is bad because this kind of metadata can’t be properly represented as JSON. How I can fix it? At least how I can say Logger to not put this metadata to output?

1 Like

I am not very sure but if you can make a small GitHub demonstrating the issue then people around here would be more willing to help.

1 Like

I’m not sure, but I think those are just crash reports that are logger by Erlang and they just don’t go through your Logstash formatter. I think you should set handle_sasl_reports to true. The docs are not really crystal clear to me, but it might work better if you’re on OTP 21+ since there was a new logger added (I’m not even sure that on OTP 21+ the handle_* flags do anything).