Skip to main content
Navigator | Tier 3
May 11, 2023
Question

"Log to File" fails in a loop.

  • May 11, 2023
  • 14 replies
  • 1035 views

I am logging a Bots action with the “Log to File” command and am getting errors saying that “The process cannot access the file because it is being used by another process.”

I created a test Bot that contains a loop command and a single log to file on a network share.

This fails with an exception every single time within a few seconds.

Has anyone else encountered this and have a solution?

14 replies

Cadet | Tier 2
April 23, 2024

Did anybody find a solution, please? The same issue started happening for us a month ago.

DeLo
Navigator | Tier 3
May 7, 2024

As mentioned in this thread, this is happening frequently and seems to be affecting many of our bots. These bots wrote their logs for so long, flawlessly. Now we’re experiencing this. All bots write to their own unique logs in a shared network location. No chance of anything else accessing them and locking them. Please advise.

Cadet | Tier 2
May 21, 2024

I was able to re-create your error in a task and faced something similar. A temporary solution until AA get’s their act together on this is to limit the amount of times you are logging to the log file. What I mean specifically is instead of logging in the loop you use a string assign command and append to a string variable. Then at the end of the loop you log once with the combined string. You can utilize the $String:Newline$ function to append the string variable with a new line. I will attach a screenshot with sample code.

Cadet | Tier 2
May 21, 2024

I was able to re-create your error in a task and faced something similar. A temporary solution until AA get’s their act together on this is to limit the amount of times you are logging to the log file. What I mean specifically is instead of logging in the loop you use a string assign command and append to a string variable. Then at the end of the loop you log once with the combined string. You can utilize the $String:Newline$ function to append the string variable with a new line. I will attach a screenshot with sample code.

I just wanted to add one more thing. You can also create a sub task with a try/catch that attempts the log multiple times. From my testing this shouldn’t impact the speed of the bot too much.