Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python logging does not release file [duplicate]

I have been using logging and notice that after first compile, the output file for logging hangs, and I cannot remove it till I close IDLE.

I believe that I should "close" logging before the compilation finish, but don't know how to do that with the way that I am using logging:

LOGFILE = os.path.join(backup_folder,'test.log')
logging.basicConfig(filename=LOGFILE,level=logging.DEBUG,format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
logging.debug('test')
like image 910
marafado88 Avatar asked Oct 19 '25 09:10

marafado88


1 Answers

So seems that I have found a way by adding in the end:

logging.shutdown()

This instruction close all handlers that was openned.

like image 185
marafado88 Avatar answered Oct 21 '25 22:10

marafado88



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!