I was following this example to implement storing log file in the esp32 flash :
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/wear-lev