Help us understand the problem. What is going on with this article?

よく使う Python ロギングスニペット

More than 1 year has passed since last update.

完全に自分向け。
DEBUG 以上のログを Hourly でローテートしつつファイルに書き出し。

import logging
from logging import getLogger, Formatter
from logging.handlers import TimedRotatingFileHandler

logger = getLogger('ConvertLog')
logger.setLevel(logging.DEBUG)
rotate_handler = TimedRotatingFileHandler(filename='convert.log', when='H')
rotate_handler.setFormatter(Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
logger.addHandler(rotate_handler)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away