loggerの使い方
テンプレート
# Logging is always nice for your experiment:)
def init_logger(log_file='train.log'):
from logging import getLogger, INFO, FileHandler, Formatter, StreamHandler
logger = getLogger()
logger.setLevel(INFO)
handler1 = StreamHandler()
handler1.setFormatter(Formatter("%(asctime)s - %(lineno)d - %(message)s"))
handler2 = FileHandler(filename=log_file)
handler2.setFormatter(Formatter("%(asctime)s - %(lineno)d - %(message)s"))
logger.addHandler(handler1)
logger.addHandler(handler2)
return logger
logger = init_logger(log_file=f'log.log')
logger.info(f'Start Logging...')