How to Copy the Latest Bot Excution log message to the my Required Folder

Suggest a method to move the Latest Bot Execution Log to the my Customized folder using Copy File Activity

To move the latest Bot Execution Log to your customized folder using the “Copy File” activity in UiPath, you can follow these steps:

  1. Get the Latest Log File:
  • You need to find the latest Bot Execution Log file. You can use activities like “Directory.GetFiles” or “Directory.GetDirectories” to list the log files in the source directory and then find the latest file based on its creation or modification date.
  1. Set Source and Destination Paths:
  • Create variables to store the source and destination file paths. For example:
    • sourceFilePath: The full path to the latest log file.
    • destinationFolderPath: The full path to your customized folder.
  1. Use the “Copy File” Activity:
  • Add a “Copy File” activity to your workflow.
  • In the properties of the “Copy File” activity:
    • Set the “From” property to sourceFilePath.
    • Set the “To” property to Path.Combine(destinationFolderPath, Path.GetFileName(sourceFilePath)). This will preserve the file name in the destination folder.

@Gopikrishna_S

Hi @Gopikrishna_S

Use this to get the latest log file:

Directory.GetFiles("C:\Path\To\Log\Directory").OrderByDescending(Function(f) New FileInfo(f).LastWriteTime).First()

Then use copy file activity at the end of the process.

Below are general steps you can follow:

  1. Locate the Log File:
  • Determine the location of the bot execution log file. This will vary depending on the bot platform or software you are using. Common locations include a specific folder on your computer or a cloud-based storage service.
  1. Check Log Timestamps:
  • Ensure that your log messages are timestamped, and the latest log entry has the most recent timestamp. This is important to identify the latest log message.
  1. Script or Automation:
  • Create a script or automation that can identify and copy the latest log message. This can be done using a programming language of your choice, or with the help of automation tools like PowerShell, Python, or batch scripting.
  1. Specify the Destination Folder:
  • Determine the location of your required folder where you want to copy the latest log message.
  1. Copy the Log Message:
  • Use your chosen scripting or automation method to copy the latest log message to the specified destination folder. This might involve reading the log file, parsing it to find the latest message, and then copying that message to the destination folder.

Define the paths to the log file and destination folder

log_file_path = “/path/to/your/logfile.log”
destination_folder = “/path/to/your/required/folder/”

Read the log file and get the latest log message

with open(log_file_path, “r”) as log_file:
log_messages = log_file.readlines()

@Gopikrishna_S

Actually What I Need is what are all the things Displaying in Output Panel that should be printed in one txt file for client reference how to do it

Actually What I Need is what are all the things Displaying in Output Panel that should be printed in one txt file for client reference how to do it?

Hi @Gopikrishna_S

Use Append line activity after each log message activity then it store to text file then you can send it to mail

@Gopikrishna_S

Check this:

will it work fine for VB Language?

@Gopikrishna_S

Yeah, you can write it on vb language. You can use invoke code activity and write the c# code(No need to create a project using C#)

@Gopikrishna_S

If you insist on writing vb code then try this code and let me know if it’s working or not.

LogWrite = Function(s)
               Dim Output As String = DateTime.Now.ToString("[MM/dd/yyyy HH:mm:ss.ffff] ") & s & Environment.NewLine
               File.AppendAllText("output.txt", Output)
               Console.WriteLine(Output)
           End Function

Hi @Gopikrishna_S

Check the below thread

Hope it helps!!