Python Programming - Log file is not capturing the data?
If any one of you faced a problem during the selenium automation using python. Where you have coded a logger file utility with the below sample code
logging.basicConfig(filename="./Logs/automation.log",
format='%(asctime)s: %(levelname)s: %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
and automation.log fine is not getting created for you in Log folder.
Solution is, use force=True
complete code is
import logging
class LogGen:
@staticmethod
def logGen():
logging.basicConfig(filename="./Logs/automation.log",
format='%(asctime)s: %(levelname)s: %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', force=True)
logger = logging.getLogger()
logger.setLevel(logging.INFO)
return logger
logfile will be created like this

