I have a software which generates .log files, and the problem is that they are not persistent (each time the programs try to write an event it might rewrite over an past event which is not desirable)
Do you know a way in which I can write a python script for detecting when the program is opening a .log file in order to write something and make sure that he is not overwriting?
Thanks!
In Python, the logging package defaults to append
import logging
logging.basicConfig(
filename=<out-path>, # to print stdout to file
format=line_format,
level=logging.DEBUG)
Then, you can write to the logfile by
logging.info(.)
or another one of logging's levels.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With