I am using the python2.x logging module for example
logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', filename='logs.log', level=logging.INFO)
I want my program to overwrite the logs.log file for each script execution, currently it just adds to the old logs. I know that the code below will overwrite, but if there is a way to do this using the registration configuration, it will look better.
with open("logs.log", 'w') as file: pass
source share