<p>I ran the following code in the python shell but it is not showing up the docker/kubernetes pod logs:</p>

<pre><code>import logging
logging.basicConfig(level=logging.INFO)
logging.info("Test")
</code></pre>

<p>This is a simplified version of what I am trying to do which is essentially run one-off scripts/commands in the python shell and have logs to show up. How do I go about getting this to work? Is it because the shell I opened up is not attached to the process that creates the logs?</p>

<p>I'm currently using Docker and Kubernetes.</p>

<p>Thanks!</p>

perseverance
<p>As <a href="https://stackoverflow.com/users/225016/matthew-l-daniel">Matthew L Daniel</a> wrote, you can cheat by using additional tools as a workaround to send your logs to stdout.</p>

<p>Also, you can import library sys and stream logs to stdout by this lib. There is an example of code:</p>

<pre><code>import logging  
import sys  

root = logging.getLogger()  
root.setLevel(logging.DEBUG)  

ch = logging.StreamHandler(sys.stdout)  
ch.setLevel(logging.DEBUG)  
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')  
ch.setFormatter(formatter)  
root.addHandler(ch)  
</code></pre>

<p>I found it on Stack, so I’ve attached <a href="https://stackoverflow.com/questions/14058453/making-python-loggers-output-all-messages-to-stdout-in-addition-to-log">link as a source.</a></p>
