0
Hello, I would like to know how to create a log file for each day. Currently saved in a single file.
log_file = path.join(path.dirname(path.realpath(__file__)),"Log.txt")
logging.basicConfig(filename= log_file, level=logging.DEBUG, format='%(asctime)s %(levelname)s %(funcName)s => %(message)s')
Thanks for your cooperation.
saved with the name {date.Today()}. txt, which change suggest I do?! , thanks in advance.
– Lorena Jesus
You used the prefix
f
indicating that it is a f-string?f"{date.today()}.txt"
– Woss
Now it worked, I think it’s the version that was not accepting the f-string, I used
log_file = path.join(path.dirname(path.realpath(__file__)), "{}.txt".format(date.today()))
and it worked, thank you :)– Lorena Jesus
Ah, yes. The f-strings are only available in versions 3.6+ of Python.
– Woss