axelclark

axelclark

I’m running a Phoenix app on Fly. I have a GenServer I’m starting as a child in my Application.start/2 function under my MyApp.Supervisor.

I had it crash within the GenServer.init/1 function when the app was starting for a deploy. In the logs there was:

{exit,terminating,[{application_controller,call,2,[{file,"application_controller.erl"},{line,511}]},{application,enqueue_or_start,6,[{file,"application.erl"},{line,380}]},{application,ensure_all_started,3,[{file,"application.erl"},{line,359}]},{elixir,start_cli,0,[{file,"src/elixir.erl"},{line,195}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}
Runtime terminating during boot (terminating)

However, the cause of the crash was not in the logs. When I tested it more, if I try to log in GenServer.init/1 during a successful start with Logger.error("Test log") it also doesn’t end up in the production logs.

The crash and logs show up when I try all these scenarios in dev using either mix or a release.

I found How do I get Phoenix or Elixir to print more detailed logs on a crash? and added:

config :logger, 
   handle_otp_reports: true, 
   handle_sasl_reports: true,
   ...

That gave me more information about the supervisor starting its children, but I still didn’t get any logs from the GenServer init function in production.

My config/prod.exs is:

config :logger,
  level: :info,
  backends: [:console, {Appsignal.Logger.Backend, [group: "phoenix"]}],
  handle_otp_reports: true,
  handle_sasl_reports: true

my config/config.exs is:

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

Any idea why I’m not getting these logs in production (either AppSignal or the console)?

Showing Posts 1 to 7

martosaur

martosaur

Don’t bother with handle_sasl_reports option, it will enable an additional error-level message, but the one you’re interested in is notice-level. This is what I see if I run your case in an empty application in a release locally:

{exit,terminating,[{application_controller,call,2,[{file,"application_controller.erl"},{line,511}]},{application,enqueue_or_start,6,[{file,"application.erl"},{line,380}]},{application,ensure_all_started,3,[{file,"application.erl"},{line,359}]},{elixir,start_cli,0,[{file,"src/elixir.erl"},{line,195}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}

18:14:35.635 [notice] Application log_app exited: LogApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: :foo
    ** (EXIT) an exception was raised:
        ** (RuntimeError) Oops
            (log_app 0.1.0) lib/log_app/application.ex:7: MyServer.init/1
            (stdlib 6.2.1) gen_server.erl:2229: :gen_server.init_it/2
            (stdlib 6.2.1) gen_server.erl:2184: :gen_server.init_it/6
            (stdlib 6.2.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Kernel pid terminated (application_controller) ("{application_start_failure,log_app,{{shutdown,{failed_to_start_child,foo,{#{message => <<\"Oops\">>,'__struct__' => 'Elixir.RuntimeError','__exception__' => true},[{'Elixir.MyServer',init,1,[{file,\"lib/log_app/application.ex\"},{line,7},{error_info,#{module => 'Elixir.Exception'}}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,2229}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,2184}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,329}]}]}}},{'Elixir.LogApp.Application',start,[normal,[]]}}}")

Which version of Elixir & OTP are you on?

I would try to run the app release locally and/or without appsignal backend as the next step.

kif

kif

There is also this No stack trace in production log - #20 by markmark206 that might be relevant.

axelclark

axelclark OP

Thanks for reproducing this! Here are my versions:

elixir          1.17.3-otp-27 
erlang          27.1.2 

I also thought that maybe the log level was the issue, but I can add Logger.error("Test log") in the GenServer.init/1 and I don’t see that in prod either. I tried it locally with both mix and as a release and the logs are all there in the terminal.

hauleth

hauleth

Are you sure that your Logger line is even called?

axelclark

axelclark OP

It gets called when I run a release locally, but I guess I’m not 100% sure if it gets called in production.

martosaur

martosaur

Alright, I think you’ve encountered this bug that was fixed in Erlang 27.2.1 Missing error logs when application crashes on OTP-26 · Issue #9163 · erlang/otp · GitHub

axelclark

axelclark OP

Amazing! Thank you!

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
mnkhod
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews