axelclark
No logs in production from GenServer init function
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)?
Marked As Solved
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
Last Post!
axelclark
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









