Artificial intelligent assistant

logger で特定のログレベルだけ分離して別ファイルにはきたい logger = logging.getLogger('default') formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s") handler = logging.StreamHandler() handler.setLevel(logging.INFO) handler.setFormatter(formatter) logger.addHandler(handler) handler2 = logging.FileHandler(filename="logs/debug.log") handler2.setLevel(logging.DEBUG) handler2.setFormatter(logging.Formatter("%(asctime)s %(levelname)8s %(message)s")) logger.addHandler(handler2) DEBUG debug logger logger logger

Python logging,

* Logging HOWTO
* Logging



`Filter`, `LogRecord` ,
()


class LevelFilter(logging.Filter):
def filter(self, record):
return record.levelname == 'DEBUG'

logger.setLevel(logging.DEBUG)
fh.setLevel(logging.DEBUG)
fh.addFilter(LevelFilter())
logger.addHandler(fh)

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 9ef060e6475043f9dff23f1f608a195f