Open alfechner opened 6 months ago
A better approach would be to use a single stream with the demux
parameter set to True
, which allows you to differentiate between stdout and stderr logs.
Hi @Khushiyant,
thanks so much for your reply and the hint to use demux
. This parameter is available for the exec_run
method but not for the logs
method I'm using.
The main difference is, that I need to intercept the stream. exec_run
returns stdout and stderr as bytes after the execution is fully done. I need to see the output right when it happens.
Ok, I get it. Let's what I can do. But, It might be delayed since it is not on next release priority
I need to stream the logs from my docker container for logging.
Currently I do this:
Now I need to differentiate between
stdout
andstderr
. Thestdout
is supposed to be logged tologger.info
, thestderr
tologger.error
.My approach is to setup two streams, one for
stdout
and one forstderr
and read them in parallel with different threads.However, messages from
stdout
andstderr
are not always logged in correct order.I also looked into ways to access the log files from the Docker JSON File logging driver I'm using directly but couldn't find a way.
Is there a way stream the messages in correct order plus the information if the message came from
stdout
orstderr
?