legoscia

legoscia

No crash reports in default Logger configuration

I just spent some time chasing down a bug that would have been easier to find if I had seen a certain crash report - but it seems like crash reports are not being shown in Elixir by default?

For example, when a process started with proc_lib:spawn crashes in Erlang, a crash report is printed:

$ erl
Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Eshell V10.0  (abort with ^G)
1> proc_lib:spawn(fun() -> error(pang) end).
<0.78.0>
2> =CRASH REPORT==== 14-May-2019::10:00:59.621479 ===
  crasher:
    initial call: erl_eval:'-expr/5-fun-3-'/0
    pid: <0.78.0>
    registered_name: []
    exception error: pang
      in function  shell:apply_fun/3 (shell.erl, line 907)
    ancestors: [<0.76.0>]
    message_queue_len: 0
    messages: []
    links: []
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 376
    stack_size: 27
    reductions: 207
  neighbours:

But not when doing the same thing in Elixir:

$ iex
Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.7.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :proc_lib.spawn(fn -> :erlang.error(:pang) end)
#PID<0.103.0>

(it’s better to use a plain spawn than proc_lib:spawn in code like this, but this is an easy way to provoke a crash report - and this is how the code I was debugging was written. With a plain spawn, we get an error report instead of a crash report, and it’s displayed clearly in both Erlang and Elixir.)

My questions:

  • Why does this happen?
  • Is this a bug or a feature? It seems to me like dropping error messages like this is incorrect, but perhaps I’m missing something.
  • Should I change my Logger configuration somehow?

Most Liked

dom

dom

Have you been able to find an answer? Enabling :handle_sasl_reports in Logger config helps, but my understanding on OTP-21+ is that error reports go directly to the logger without involving SASL, so I don’t get why the flag would be needed.

It’s a problem in dev because I need to choose between enabling the flag, which adds a ton of log spam due to SASL progress reports, or not enabling it, in which case processes die completely silently…

Edit: Perhaps it’s because Elixir calls the old :error_logger:

So the error reports go through SASL, unlike the Erlang ones, which use the new logger directly:

hauleth

hauleth

You still could use:

config :logger, :console,
  format: "[$level] $message\n"

As config will be automatically merged for 1 level.

as of erlang 21 handle_otp_reports must be set although true is the default

This is not true, you need only :handle_sasl_reports as handle_otp_reports: true is default (trust me, I have written Logger for Elixir 1.10+). The only thing is that :handle_sasl_reports will be ignored if :handle_otp_reports is false (which with current implementation is quite problematic, and IMHO setting handle_otp_reports: false should be deprecated).

hauleth

hauleth

Which version of Elixir do you use? Maybe I will be able to pinpoint the problem.

lud

lud

runtime_tools is added by mix phx.new, and adding sasl is recommended by many sources I read. Also that as of erlang 21 handle_otp_reports must be set although true is the default (which makes no sens). But all of this is wrong actually (at least on my ex/erl versions), and you are right.

This works well then, if anyone else wants to keep custom console format:

config :logger, 
  console: [format: "[$level] $message\n"],
  handle_sasl_reports: true

I forgot about the config format, and was setting all those options only for the console display options.

Thank you ! (Oh and I found my error, I have to use a rest-for-one strategy, so thanks again)

Where Next?

Popular in Questions Top

gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement