Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'output': 0.04; 'true,': 0.04; 'none:': 0.05; 'class,': 0.07; 'formatting': 0.07; '**kwargs)': 0.09; '**kwargs):': 0.09; 'cmd': 0.09; 'executes': 0.09; 'logger': 0.09; 'received:138': 0.09; 'received:localnet': 0.09; 'stdout': 0.09; 'def': 0.10; 'skip:p 40': 0.15; 'command,': 0.16; 'empty.': 0.16; 'subject:Logging': 0.16; 'true:': 0.16; 'working.': 0.17; 'thanks,': 0.18; 'skip:p 30': 0.20; 'to:name :python-list@python.org': 0.20; 'file:': 0.22; 'received:74.125.82.174': 0.23; 'command': 0.24; 'header:User- Agent:1': 0.26; 'logging': 0.27; 'actual': 0.28; 'catching': 0.29; 'class': 0.29; 'returned': 0.30; 'file': 0.32; 'print': 0.32; 'received:74.125.82': 0.33; 'skip:s 30': 0.33; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'skip:l 30': 0.35; 'there': 0.35; 'created': 0.36; 'but': 0.36; 'received:74.125': 0.36; 'method': 0.36; 'should': 0.36; 'charset :us-ascii': 0.36; 'two': 0.37; 'being': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'hello,': 0.39; 'header:Received:5': 0.40; 'skip:n 10': 0.63; 'florian': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xgm.de; s=google; h=from:to:subject:date:message-id:user-agent:mime-version :content-transfer-encoding:content-type; bh=JhBi02xtiSH3CDZVZ+f5Wgcgy5xH7Qo6oTxldJF7I6g=; b=hxjLWmWbtolTUJ5bHOQpGqDRT6U5mWyJWe2+qolERK6N3tCAXSRlIRYSbfa9cEcx7d 0fcZiRIJzsz0QpPBlaap0Vrg2lwxLq/rDOvaW06cApE5HN0lglNW9WxHyU3vo4TZlqh1 EfUyHJ8WTMp6fZxPc3T1Axex7c0fMLMLL2aaI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-transfer-encoding:content-type:x-gm-message-state; bh=JhBi02xtiSH3CDZVZ+f5Wgcgy5xH7Qo6oTxldJF7I6g=; b=eZSa1GKHJPzSdbFr4G+QlIItV6Xvy0HCHvia9iyl1rXv2jF2TzHnAdbWlYJ51Ow1VV A9oVQy9XoqW5nJhf3+zq5tKlvW23JdxKWPX8GrEyMwWbvZtAs8cGPWtyta/VxX3ONC7a uG23kskoK46rBunXq/YTjYd9bJvcA1+lgdG8qaayoMsaW6rIcvMI0MG+Yd3F8mhtm7tw dgQH+wfNnu0fFtD3iPUE75NWfwoEVuaE10G/6qzI2/aseuEG7XF43yXSkzipU/YvS3p+ pJ9KcFHV2LcqZGOkX8ZCOhFG0UcP3aYrUqjEqtQdIs9q5JDeeL0gV5YH433iiiNtec53 2oNQ== From: Florian Lindner To: "python-list@python.org" Subject: Logging handler: No output Date: Sun, 02 Sep 2012 13:12:34 +0200 User-Agent: KMail/4.9 (Linux/3.5.3-1-ARCH; KDE/4.9.0; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Gm-Message-State: ALoCoQl7Os51l/XIqMW+1fxsUlI3YP4QsBzhzQLtRjhA9SuhGUf0FKXcKdKBcB+rKJcx4HMjVGb2 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346584357 news.xs4all.nl 6937 [2001:888:2000:d::a6]:58331 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28264 Hello, I have a class method that executes a subprocess. There are two loggers in the class, self.logger for general logging and proclog for process output (stdout & stderr) logging which should go to stdout and a file: def start_process(self, command, no_shlex=False, raise_excpt=True, print_output = True, **kwargs): cmd = command if no_shlex else shlex.split(command) # Use an additional logger without formatting for process output. proclog = logging.getLogger(self.config.tag) proclog.propagate = False # Process output should not propage to the main logger logfile = self._logfilename() if logfile: proclog.addHandler(logging.FileHandler(logfile)) if print_output: proclog.addHandler(logging.StreamHandler(sys.stdout)) self.popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=0, **kwargs) while True: output = self.popen.stdout.readline().decode() if output == "" and self.popen.poll() != None: break proclog.info(output.rstrip("\n")) ret_code = self.popen.returncode self.logger.debug("%s returned with %i", command, ret_code) But neither the FileHandler nor the StreamHandler produce any actual output. The file is being created but stays empty. If I use a print output in the while loop it works, so output is catched and the applications stdout in working. But why the logger proclog catching nothing? Thanks, Florian