Hi,
I am writing some log file, and when I run each time I want to flush out everything (don't want to keep any previous data) I use the below code, but it is not working, I also tried with "w+", "a", and "a+" mode, still does not work. Kindly help how to fix it.
I am writing some log file, and when I run each time I want to flush out everything (don't want to keep any previous data) I use the below code, but it is not working, I also tried with "w+", "a", and "a+" mode, still does not work. Kindly help how to fix it.
import logging
# log messages to a file, ignoring anything less severe than ERROR
logging.basicConfig(filename='myprogram.log', filemode = 'w', level=logging.ERROR)
# these messages should appear in our file
logging.error("The washing machine is leaking!")
logging.critical("The house is on fire!")
# but these ones won't
logging.warning("We're almost out of milk.")
logging.info("It's sunny today.")
logging.debug("I had eggs for breakfast.")

