I\'m using TensorFlow-Slim, which has some useful logging printed out to console by tf.logging
. I would like to redirect those loggings to a text file, but couldn\'
import logging
# get TF logger
log = logging.getLogger('tensorflow')
log.setLevel(logging.DEBUG)
# create formatter and add it to the handlers
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# create file handler which logs even debug messages
fh = logging.FileHandler('tensorflow.log')
fh.setLevel(logging.DEBUG)
fh.setFormatter(formatter)
log.addHandler(fh)
My solution is inspired by this thread.