Logging handler: No output

Vinay Sajip vinay_sajip at yahoo.co.uk
Sun Sep 2 13:02:11 EDT 2012


Florian Lindner <mailinglists <at> xgm.de> writes:

> 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?
> 

Paul Rubin's answer looks correct. In addition, you should note that every call
to start_process will add a new handler to the logger (I can't tell if the
logger could be the same on multiple calls, but it seems likely) and that may
produce multiple messages. The rule of thumb is: most code should get loggers
and log to them, but adding handlers, setting levels etc. should be only done in
one place (typically invoked from a "if __name__ == '__main__'" clause.

Regards,

Vinay Sajip




More information about the Python-list mailing list