Better way to view container logs?

If I need to view the logs of a container, I currently either use the web console to access the host OS or balena ssh (ip address) to the device.

Then I have to run balena ps to find the container ID, then run balena logs (container ID) to get the logs.

Is there a simpler / easier way to do this?

Hi @jgentes,

If you are just casually viewing the logs of application containers, you should be able to use the Logs modal on the dashboard. You can additionally filter those logs by message, service, system message, or timestamp.

If you are trying to develop more effectively, you should be able to view logs directly as you build & push code if you use the live push feature. One of our engineers recently wrote a great description of live push and all it’s use cases, you can read more here: https://www.balena.io/blog/living-on-the-edge-with-livepush-and-other-cli-improvements/. There is further documentation here as well: https://www.balena.io/docs/reference/cli/#push-applicationordevice.

Furthermore, if you’d like to tail those logs in your terminal and the container names are predictable, perhaps you could use standard SSH & a tunnel to access them directly (and programmatically). More has been written about tunneling here: Rsync over balena ssh tunnel?.

If you are doing something more with the logs, could you describe a little more about what you are trying to do?

Thanks Matthew, I’m working on static IP configuration, so the environment is a bit difficult to maintain a consistent connection to. I’m using persistent logging to figure out what happened if the device doesn’t come back online after an IP change.

Live push is cool, but it requires local mode, which for some reason seems to airgap the device - it can’t connect to our web service and therefore is hard to troubleshoot as it would behave in a normal environment. So that’s not a super useful option, although I wish it were.

I haven’t looked at the ssh tunnel so that may be interesting. I’ll take a look at that.

I’d like to learn more about your application and how it is conflicting with livepush as this should not be the case and may reflect a bug in livepush itself. How do you typically connect to your webserver?