次のコードは、「ipython qtconsole」で「I want this to print」を出力しますが、プレーンな IPython では出力しません。
import logging
import logging.handlers
log = logging.getLogger()
f = logging.Formatter("%(asctime)s - %(module)s. %(funcName)s - %(levelname)s - %(message)s")
fh = logging.handlers.TimedRotatingFileHandler('log.txt', 'W6')
fh.setFormatter(f)
log.addHandler(fh)
log.setLevel(logging.INFO)
log.info('I want this to print')
「IPython qtconsole」では、ここで説明しようとしたさまざまな問題が発生します(うまくいかなかったので、読む必要はありません!)。
理由を教えてください。
編集:私はPython 2.7を使用しています
EDIT2:本当にlogging.StreamHandlerを追加する必要があるかもしれません。