I would like to output this log file into a text file for review once the bot is completed and also send this to the client. I read online to use an invoke code process but that didn’t seem to work
Sample -
05/23/2022 14:53:47 => [Debug] Percentage of address match: 0.866666674613953
05/23/2022 14:53:47 => [Info] The total is more than 80%
05/23/2022 14:53:47 => [Info] This is the PIN from the data scrape: 30194105
05/23/2022 14:53:47 => [Info] This is the PID from the Master Sheet: 30194104
05/23/2022 14:53:47 => [Info] What is the current row:3
05/23/2022 14:54:15 => [Info] Updated the PIN number due to not matching
05/23/2022 14:54:16 => [Info] This is the Effective Date 11/01/2014
05/23/2022 14:54:16 => [Info] This is the Scraped Date 11/01/2014
05/23/2022 14:54:16 => [Info] Both dates matched
05/23/2022 14:54:33 => [Debug] This is the NPI 1043221039
05/23/2022 14:54:39 => [Debug] Number of records found in search 1
I would like to export this file, not manually each time but write it to a text file.
Man, that is a seriously over-engineered solution.
I would not recommend following that posts approach its very clunky.
There is an activity already called ‘Write Line’ which will output it the text to the logs, but it also has a ‘TextWriter’ property where you can add a TextWriter, which can easily be used to output to a text file. Pretty simple.
It does mean you need to switch out your Log Messages for Write Lines however.
There are other ways of doing it which are smoother and allow you to capture the data from log events, but it involves making custom activities in .Net
Just ran it and it did not write the output to the file folder,
LogWrite = (s) => {
string Output = DateTime.Now.ToString("[MM/dd/yyyy HH:mm:ss.ffff] ") + s + Environment.NewLine;
File.AppendAllText(“files\output.txt”, Output);
Console.WriteLine(Output);
};
Like this, its super easy. The second assign that isn’t fully visible is just setting the Autoflush property to true, do that otherwise you need to flush manually.
I would strongly recommend against the other posted solution.
You cannot capture that log window in either of the methods demonstrated here, the one in the link has a nasty cumbersome way to set up a custom way to log messages that go to a custom log file. I provided a simpler cleaner one, but it only logs things in the ‘Write Line’ activity. (The other custom log also doesn’t capture those extra messages).
As the question " I would like to output this log file into a text file for review once the bot is completed and also send this to the client. " so invoke code is not good solution and bot will automatically download the log file and share it to business.
You suggested it could be possible by write line I have same scenario and please help me to overcome this problem appreciate you.
Neither solution, using the invoke code nor the write line activity are downloading the log file and neither are grabbing all the log messages, for example neither will capture any error messages thrown.
What they both do is provide a way to log a message that appears both in the output panel and to a custom log file. My stance is that, for such a simple function, using the invoke code method is very cumbersome when you can just use Write Line and a TextWriter Class.
To capture all of the logs there are two choices, one is to make an API call to download the logs for the current job, however you need the Job ID in order to do that which is not easy to expose. Its situationally possible to grab these logs based on other filters, but it will bot be reliable.
The other method involves hooking into the underlying logging class on the robot runner to register your own log listener.
Both of these require advanced knowledge of coding (to get the Job ID or register a listener) and making custom activities in Visual Studio.