Hi @Santosh7 ,
Please find some samples of Use case how to write logs to text file.
Case1: First you need to setup the variables as shown in the below image and need to call or run that subflow to write the log to the text file as shown in image 1.
Image 1:

Case 2: You need to setup in on error to write the error message logs to text file as shown in below image 2.
Image 2:

Case 3: Create a sub flow as shown image 3 and call it wherever it is required.
image 3:


Case 4: It will write to the text file as shown in image 4:

(Note:- if you got your solution you can mark as solution and gives kudos)
Thanks & Regards
Vishnu Reddy