Create Log File

Hello friends, (@balupad14, @rkelchuri, @Rammohan91, @loginerror)

how is it possible to create a log file, for example a txt file, to track all the errors of the execution of the bot?
The customer wants to have a look at all the possible errors of the bot, in order to track of the errors?
Which activities can I use?
Thank you so much,
Camilla :slight_smile:

you need to use the log message Activity

1 Like

Thank you @reda
But how to save the error in the log file?
Thank you,
Camilla :slight_smile:

Hi @CamiCat

well change the level to Error first in the activity and then write your custom message inside the Message area.

The error level is normally used inside a catch block where you want to log the fact that the robot had some errors in the try section.

1 Like

Hey @CamiCat, I can think of a simple solution if you just want to deal with logs in a text file. Just use ‘Append Line’ activity within the catch block of the workflows. You may need to make sure that the path/name of the txt file that you use is same wherever you may wanna capture the logs. Also, just make sure that exception is handled for all the activity.

Few things you may wanna implement:
→ Add today’s date as the name of the file, so that you will have a new log file for each day. (Note: ‘Append Line’ activity will create a new file, you just dont have to create file before running the process)
LogFileName = "Logs\Logs-" + Today.ToString("ddMMyyyy") + ".txt"
→ For each exception you may wanna capture the date and time when it was thrown as well. You can use something like this under ‘Text’ attribute for your Append Line activity:
DateTime.Now.ToString + ": Application Failed to Launch." + e.Message

Let me know if it helps.

Thanks,
Rammohan B.

5 Likes

Thank you so much @Rammohan91.
I think this is the solution for my case.
I try and let you know as soon as possible.
Thank you so much for your kindness.
Camilla.:slight_smile:

1 Like

You can use this activity.

Regards
Balareva

5 Likes

Please use UiPath.Core.Activities.AppendLine activity.

This will create your custom log file.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.