Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
To address your issue with container logging in Torizon OS, let’s break it down into two parts:
1. Viewing Container Logs
Your C code snippet should indeed send output to stdout, which Docker captures and makes available via docker logs. Here are a few steps to troubleshoot why docker logs -f isn’t showing your output:
-
Ensure the Container is Running: Make sure your container is actually running. You can check this with
docker ps. -
Check the Container ID: Ensure you are using the correct container ID or name with the
docker logscommand. -
Verify the Logging Driver: By default, Docker uses the
json-filelogging driver, which should capturestdoutandstderr. You can verify this by running:docker inspect --format='{{.HostConfig.LogConfig.Type}}' <container_id>It should return
json-file. -
Run a Simple Test: Try running a simple container to see if logging works:
docker run --rm -it busybox sh -c 'while true; do echo "Hello all"; sleep 1; done'Then, in another terminal, run:
docker logs -f <container_id>This should show the “Hello all” messages.
2. Enabling Container Monitoring with Fluent Bit
To enable container monitoring with Fluent Bit in Torizon OS, follow these steps:
-
Enable Fluent Bit: Ensure Fluent Bit is enabled on your Torizon OS device. This is typically done by provisioning the device to Torizon Cloud, which creates the
/etc/fluent-bit/enabledfile. -
Configure Docker to Use Fluentd Logging Driver:
- Edit your Docker Compose file to use the Fluentd logging driver. Here is an example:
version: '3.8' services: my_service: image: my_image logging: driver: fluentd options: fluentd-address: localhost:24224 tag: docker.my_service
- Edit your Docker Compose file to use the Fluentd logging driver. Here is an example:
-
Configure Fluent Bit:
- Ensure Fluent Bit is configured to accept logs from Docker. Add the following to your
/etc/fluent-bit/fluent-bit.conf:[INPUT] Name forward Listen 0.0.0.0 Port 24224 [OUTPUT] Name stdout Match *
- Ensure Fluent Bit is configured to accept logs from Docker. Add the following to your
-
Restart Fluent Bit:
systemctl restart fluent-bit -
Run Your Container:
- Start your container with the updated Docker Compose file.
-
Check Fluent Bit Output:
- Open a terminal and run:
journalctl -u fluent-bit -f - This should show the logs being forwarded from Docker to Fluent Bit.
- Open a terminal and run:
Missing Documentation Link
Regarding the missing link in the “Enabling Container Monitoring” section, it seems there might be an issue with the documentation. You can refer to the official Docker documentation for configuring logging drivers in Docker Compose files: Docker Logging Drivers.
By following these steps, you should be able to see your container logs and configure Fluent Bit for container monitoring in Torizon OS. If you continue to face issues, please provide more details, and we can further troubleshoot.
Please, also check if these links can help you solve your problem: