Export log from Output panel to text file

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:
  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);
  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.