Export log from Output panel to text file

Hi everybody! please help me. I need export to text file from all information in output panel. I tried but still could not do it.

Would using the log file suit your needs? The log folder is located in %localappdata%\UiPath\Logs

Or perhaps the Export Logs button?

1 Like

Hi OpalSnow,
i wanna get content is displayed in output panel to export custom text file.
Can i use any activities?
Thanks

Hello.

So in order to answer that we’ll need some more information about your project. What is the reason you would like to export the log output to a file?

Because if its only to easen development for yourself I would take a different approach than if it would be logs to be able to debug the robot.

1 Like

hi.

My project manager requested that. He want to tracking the BOT execution like output panel with timeStamp.
image

After playing around a bit in UiPath Studio I came up with the following idea:

We’ll use the Invoke Code activity to create a Lambda function (a.k.a arrow function). We’ll assign the Lambda function to a variable that we’ll use globally in our project. This function will be used to write the output to your log file and to your Studio’s output window.

  1. Create the variable named LogWrite of type Action<String> and set its scope to your process’ main sequence or flowchart. See image below:
    afbeelding
  2. Add the Invoke Code activity to the beginning of your project and set the activity’s language parameter to CSharp.
  3. Click Edit Code and add the following code:
LogWrite = (s) => {
	string Output = DateTime.Now.ToString("[MM/dd/yyyy HH:mm:ss.ffff] ") + s + Environment.NewLine;
	File.AppendAllText("output.txt", Output);
	Console.WriteLine(Output);
};
  1. Click Edit Arguments and set the following argument. See image below:

You are now able to use the Invoke Code activity (language CSharp) to trigger the code:

LogWrite("My message")

Use the same arguments as mentioned in step 4.

You can use this throughout your entire project to write log outputs to your UiPath Studio output pane and to “output.txt” which is located in your project’s main folder. I’ve added the number of milliseconds to the timestamp, allowing you to debug and measure performance more precisely.

The key here is to use File.AppendAllText(string path, string text). Whichever logic you build around that is totaly up to you.

3 Likes

Thanks Bro!

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