This article is somewhat water Ha , Just look at it
import logging
logger = logging.getLogger()
# Set output level ,debug The lowest level , higher than debug All levels will output
logger.setLevel(level=logging.DEBUG)
''' Create a handler, For output to console '''
hh = logging.StreamHeadler()
''' Create a handler, For writing log files '''
hl = logging.FileHandler("output/log.txt")
''' take logger Add to handler Inside , Start automatic update '''
logger.addHandler(hh)
logger.addHandler(hl)
in the light of detectron2 Training for , Copy and paste it into the main function of the training code , In the process of training ,pycharm Console (console) and log.txt There will be log output , It is convenient to carry out comparative test
python in logging Detailed explanation of log module