Page 1 of 1

Text File Log File

Posted: Wed Jun 25, 2014 12:52 pm
by hjr
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 ;)

Re: Text File Log File

Posted: Mon Jun 30, 2014 3:42 pm
by Support Team
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)

Re: Text File Log File

Posted: Mon Jun 30, 2014 4:13 pm
by krstcs
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.

Re: Text File Log File

Posted: Wed Jul 02, 2014 3:32 pm
by hjr
Thank you very much Markus , this is exactly what I was looking for !

Re: Text File Log File

Posted: Thu Jul 03, 2014 2:17 pm
by hjr
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!

Re: Text File Log File

Posted: Thu Jul 03, 2014 3:06 pm
by Support Team
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)

Re: Text File Log File

Posted: Fri Jul 04, 2014 2:02 pm
by hjr
Perfect!

Thank you :wink:

Re: Text File Log File

Posted: Mon Jul 07, 2014 2:17 pm
by krstcs
Haha! At the time of the original post of the code it wasn't yet on the download page... I checked! :D