there's a problem getting messages from a program's logger, if this program is called with subprocess.
Here's the program BooFoo.py that uses logger to print messages to a file and console window:
import logging LOG_FILENAME = 'example.log' logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) logger = logging.getLogger('main') logger.addHandler(logging.StreamHandler()) print 'print foo' logger.info('logger boo') Here's the program CallBooFoo.py:
import subprocess proc = subprocess.Popen(['python BooFoo.py'], bufsize=512, stdin = None, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True) proc_out, proc_err = proc.communicate() print proc_out "logger boo" does not get printed with CallBooFoo.py. Any idea how to fix this? Using os.system works, but is not a solution due to some other reasons.