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)
- you were not logging the message
%(asctime)s- %(message)s
as well as instead of ‘w’ you should use ‘a’ (append)
4
solved How to had try exception to log to logger using python