Elixir Terminal output on Fly.io

I apologize for a tremendously basic question…

I have an Elixir Phoenix back end app that is serving to an electron app. On my local system, everything is working… deployed in pseudo production, I’m having a few issues. When run locally, I have running terminal output that lets me see incoming requests, and key errors.

When I SSH in, the app is running as a service in the background… which obviously does not show terminal output.

Is there a way to get the same information in Fly? The live logs seem to be the machine state, rather than software application state.

Hi… No worries! There is no minimum bar for question complexity on the Fly forum, :sweat_smile:

What do you see in the way of :logger settings in config/dev.exs versus config/prod.exs ?

Thanks!

In config.exs

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

In dev.exs

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

In prod.exs

config :logger, level: :info

I believe you can just change that last one to level: :debug and then re-deploy.

(Typically, production logging is less verbose than development, otherwise most people would find the useful parts drowned out by prosaic “Got another request and sent another 200 OK” repetitions…)

Unfortunately, not working. The only logs that register are when I spin up a new image.

I’d suggest posting those logs—the ones that you do have. Otherwise, we forum readers are short on context.

After boot, there would generally be Preparing to run `/app/bin/server`, the address that Cowboy is binding to, …

I think I got the logs to show, but multi-line output is quite… annoying…

If I print an object, then the each line of the object gets a new timestamp and row, and it’s not formatted like it would be on a terminal. Is there anyway to adjust this setting?

Glad to hear there was progress…

I may be misunderstanding what you’re trying, but the logging system is principally for gruff, rather isolated, one-liner notifications. (“New SSH login from user mayailurus@example.com.”) It isn’t really intended to visually reproduce 2D output—not when it comes to minutiae like column alignment and VT-100 effects.

Maybe it would be easier† to change your CMD (or similar) to…

bash -c 'set -o pipefail && /app/bin/server | tee /tmp/raw-stdout.log'

(Might need tweaking for local conditions, :open_umbrella:.)

Then tail -F /tmp/raw-stdout.log from an SSH session.


†This is a middle ground in that it will generally miss the fancy escape codes for colors and the like—but should preserve other formatting.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.