I am trying to empty a log file created in logging.ini as shown below, with this approach it clears the contents but the empty spaces of the contents still exist and then the new contents will be appended to it.
[handler_filehandler]
class=FileHandler
level=DEBUG
formatter=json
args=("../logs/test_log.log",'w')
fn_path = os.path.join(os.path.dirname(__file__),
'..',
'logs',
'test_log.log')
fn_path = os.path.abspath(fn_path)
with open(fn_path, 'w'):
pass
Have attached a image below of log when I open it in notepad
it shows empty contents on the second run of my application at first run there are no empty line, i clear the log once the first run is done , on the second run the logs are added after empty line
How can I clear all the contents without any empty spaces left in log file