all Python 3loggingfunction
logging.shutdown()
configuration
Flushes and closes all logging handlers. It runs by itself when the program exits normally.
Syntax
logging.shutdown()
logging registers it with atexit, so you rarely call it by hand. But os._exit() and a process killed by a signal bypass atexit, and the buffered tail of the log is lost. Do not use logging after shutdown(): the handlers are closed and writes to a file may silently fail to happen.
Examples
import logging
log = logging.getLogger('job')
log.addHandler(logging.FileHandler('job.log', encoding='utf-8'))
log.warning('готово')
logging.shutdown()
with open('job.log', encoding='utf-8') as f:
print(f.read(), end='') # → готово
See also
Open in the full glossarydocs.python.orgReport an inaccuracy