From 6ce5c1ab30f394bd478d8d81f0762ac1f521a551 Mon Sep 17 00:00:00 2001 From: Shashank Hegde Date: Mon, 6 Sep 2021 13:12:33 -0400 Subject: [PATCH] Update logger to clear old handlers https://stackoverflow.com/questions/30861524/logging-basicconfig-not-creating-log-file-when-i-run-in-pycharm/61322798 --- thumbnail_maker.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/thumbnail_maker.py b/thumbnail_maker.py index d868f83..39041ca 100644 --- a/thumbnail_maker.py +++ b/thumbnail_maker.py @@ -7,7 +7,9 @@ import PIL from PIL import Image - +# the below 2 lines are necessary to remove any handlers. If you don't see loglines in your log file, try adding these 2 line +for handler in logging.root.handlers[:]: + logging.root.removeHandler(handler) logging.basicConfig(filename='logfile.log', level=logging.DEBUG) class ThumbnailMakerService(object): @@ -73,4 +75,4 @@ def make_thumbnails(self, img_url_list): end = time.perf_counter() logging.info("END make_thumbnails in {} seconds".format(end - start)) - \ No newline at end of file +