
Good day,
I have to log each decision making or milestone points in a log file for debugging purpose/tracing/log purpose.
Example:
File name: Logfile_1.txt
File content should be like this :
27-05-2023 10:33:44 : My Bot Process Step : 1
27-05-2023 10:37:01 : My Bot Process Step : 2
27-05-2023 10:39:00 : My Bot Process Step : 3
27-05-2023 10:41:20 : My Bot Process Step : 4
27-05-2023 10:46:51 : My Bot Process Step : 5
Activity :
Get current date and time : i dont want use this activity again and again to get the date and time. (every time prior write to log file / text file)
Is there a way I can achieve this ?
This is what happening which I dont want:
or to use the get current date and time activity every time :
Thanks in advance!
Run cmd instead. This should be able to append a line to the .txt without ever having to open it.
echo %date:~4,10% %time:~0,5% Step 1 Completed >> C:\Documents\Logfile.txt
in this code, it gets the date and time in a specific format. I believe the 4 gets you the proper regional setting, so hopefully you don’t have to adjust. “Step 1 completed” can be whatever you want, and then it appends it to the logfile on its own line. Replace the file path with the proper one.
this will take you from having two separate actions to just having one, and it should be able to send off the cmd command and then continue to run while cmd writes to the txt file.
best of luck!