Open GoogleCodeExporter opened 9 years ago
Indeed, the problem is that the remote python engine initializes logging and
the call to basicConfig in your script is ignored.
As a workaround use the following:
import logging
LOG_FILENAME = 'test_example5.log'
fh = logging.FileHandler(LOG_FILENAME)
fh.setLevel(logging.DEBUG)
logger = logging.getLogger()
logger.addHandler(fh)
logger.debug('This message 1')
logger.debug('This message 2')
fh.close()
Original comment by pyscripter
on 6 Sep 2012 at 12:15
I can't seem to find a way to fix logging to the console (sys.stdout). Any
advice on that? I've tried the following, among other things:
import sys
consoleLogHandler = logging.StreamHandler(sys.stdout)
consoleLogHandler.setLevel(logging.DEBUG)
consoleLogHandler.setFormatter(logging.Formatter('%(message)s'))
logging.root.addHandler(consoleLogHandler)
Original comment by pckuj...@gmail.com
on 10 Sep 2012 at 7:40
Oh, and I should mention that, when using the Internal Python engine,
basicConfig works fine ( logging.basicConfig(level=logging.DEBUG,
format='%(message)s') ). It's only with the External engine that logging
disappears.
Original comment by pckuj...@gmail.com
on 10 Sep 2012 at 7:41
Exactly, I had mentioned that in the "workaround" part when I reported the bug:
--- Please provide any additional information below.
Work around: switch to "Internal" Python engine
Original comment by cynosure...@gmail.com
on 11 Sep 2012 at 11:34
I can't remember how to reproduce it but it is also possible for the Internal
Python engine to fail logging (and to file) too if you use both basicConfig and
addHandler incorrectly.
Original comment by yho2...@gmail.com
on 2 Aug 2013 at 1:48
Original issue reported on code.google.com by
cynosure...@gmail.com
on 29 Aug 2012 at 1:28