Text File Log File

Ranorex Spy, Recorder, and Studio.
hjr
Posts: 4
Joined: Wed Jun 25, 2014 12:45 pm

Text File Log File

Post by hjr » Wed Jun 25, 2014 12:52 pm

Hi,

I would like to know if it is possible to generate .txt log files using Ranorex 5?
I found the following information:
"The Ranorex Logger supports the following output formats:

Console text
Text file
XML file

The code: Logger.Initialize(true, "test.txt", "test.xml", LogLevel.Info); "

But this is only for Ranorex 1.x , so I was wondering if something similar was available for Ranorex 5.

Thank you in advance ;)

User avatar
Support Team
Site Admin
Site Admin
Posts: 12169
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Text File Log File

Post by Support Team » Mon Jun 30, 2014 3:42 pm

Hi hjr,

In order to generate a Report as .txt file you have to write your own ReportLogger.

Please have a look at the attached Sample Project.
This contains a textReporter class, which can be used to write the Reports into a txt file.

Please also have a look at the Program.cs file in this project, there you can see the changes I've made to use this textReporter.

regards,

Markus (S)
Attachments
TXTReport.zip
(12.36 KiB) Downloaded 322 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Text File Log File

Post by krstcs » Mon Jun 30, 2014 4:13 pm

Markus,

Don't know if you realized it but you created the solution with 5.1.0 instead of 5.0.3. :D

Are you teasing us?? :P


Other than that, very handy.
Shortcuts usually aren't...

hjr
Posts: 4
Joined: Wed Jun 25, 2014 12:45 pm

Re: Text File Log File

Post by hjr » Wed Jul 02, 2014 3:32 pm

Thank you very much Markus , this is exactly what I was looking for !

hjr
Posts: 4
Joined: Wed Jun 25, 2014 12:45 pm

Re: Text File Log File

Post by hjr » Thu Jul 03, 2014 2:17 pm

Hello Markus,

I have tried the code and it works fine. I still have a question : is there a way to append to the report, or is it always overwritten?

Thanks again!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12169
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Text File Log File

Post by Support Team » Thu Jul 03, 2014 3:06 pm

Hi,

I am glad that I could help you :)

regarding the question how to append to the report:
You can use
System.IO.File.AppendAllText(filename,text);
instead of
System.IO.File.WriteAllText(filename,text);
in the End()-method of the textReporterclass.

@krstcs

I did not want to tease you, but as you may have noticed, the version was already released ;)

regards,
Markus (S)

hjr
Posts: 4
Joined: Wed Jun 25, 2014 12:45 pm

Re: Text File Log File

Post by hjr » Fri Jul 04, 2014 2:02 pm

Perfect!

Thank you :wink:

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Text File Log File

Post by krstcs » Mon Jul 07, 2014 2:17 pm

Haha! At the time of the original post of the code it wasn't yet on the download page... I checked! :D
Shortcuts usually aren't...