title: Python logging and subprocess ouput and error stream
body: <p>I would like to start off a python process and log subprocess error messages to the logging object of the parent script. I would ideally like to unify the log streams into one file. Can I somehow access the output stream of the logging class? One solution I know of is to use proc log for logging. As described in the answer below, I could read from the proc.stdin and stderr, but I'd have duplicate logging headers. I wonder if there is a way to pass the file descriptor underlying the logging class directly to the subprocess?</p>
  
  <pre><code>logging.basicConfig(filename="test.log",level=logging.DEBUG)
  logging.info("Started")
  procLog = open(os.path.expanduser("subproc.log"), 'w')
  proc = subprocess.Popen(cmdStr, shell=True, stderr=procLog, stdout=procLog)
  proc.wait()
  procLog.flush()
  </code></pre>