[Solved] How to had try exception to log to logger using python
[ad_1] I have modified your script and it’s working import os import logging import sys logging.basicConfig(filename=”log.txt”,level=logging.INFO,format=”%(asctime)s- %(message)s”,filemode=”a”) def checkfileexist(Pth,Fle): var=Pth+”https://stackoverflow.com/”+Fle try : if (var is None): logging.error(‘Path is empty’) raise Exception(“empty path”) if os.path.exists(var): logging.error(‘File found’) return (var) else: raise Exception(“File Not found”) except Exception as e: logging.error(‘Not Found file’) sys.exit() def additionvalue(a,b): return (a+b) … Read more