Log file creation in Python vs Shell
<p>I am having a difficult time to understand log creation on Python. I come from shell programming and trying to see if a similarity exists b/w shell and Python logging</p>

<p>In shell- I have a driver script where I describe the log location and name  . Log from all the scripts that I call from the diver will be directed to the log</p>

<p>Example
driver script.ksh</p>

<pre><code>#!bin/ksh
master_log_file = home/path1/masterlog

call script1
 script1.ksh &gt;&gt; master_log_file
</code></pre>

<p>how do i same thing in python</p>

<p>Example
driver script.py</p>

<pre><code>#!bin/env/python

#create master log file

# call script1.py
 script1.py &gt;&gt; master_log_file
</code></pre>

<p>Best way to create logs in python is with a logging library documented here: <a href="https://docs.python.org/3/library/logging.html" rel="nofollow">https://docs.python.org/3/library/logging.html</a> </p>

<p>It's pretty sofisticated and can be a pain to set up when you want to your logging to be sofisticated (log different levels to different outputs etc). But once you get it working properly, it can do some amazing things for you, logs the origin (module), you can pass an argument to just log certain level (info) for normal running and another (develop - with loads of details) for another. </p>

<p>For example, one of my scripts logged info stuff to stdout, so I had logs of what was going on easily readable, while it also logged debug stuff to a file, so when a bug appears, I could see log information from all the libraries etc. That wouldn't be practical in stdout, because it wrote whole objects out and everything. </p>

python shell logging