Multi container app logs not interlaced

Is it possible to get interlaced logs from two containers in a multi container app? An internet search says this should happen by default. However in my app the first container to start prints logs continuously, but the second container to start only prints logs when it stops.

There doesn’t seem to be a setting in the docker compose yaml file or the docker start command?

Yes, it’s possible to get interlaced logs from two containers in a multi-container app. The issue might be related to the logging driver or the way the application outputs logs. Check the logging configuration and ensure both containers use a compatible logging driver.

Isn’t that a Python container? In case of Python, when you use print to send something to the standard output, it is buffered which can be disabled by setting the env variable PYTHONUNBUFFERED=0 in the container or I found that the print function has a flush=True agument as well.

I also heard that when you use a logger, that also sends the output correctly to the standard streams

1 Like