Logs are very important for tracking the defects. We can know exactly where the code is failing to do our defined task.
Do we have any predefined methods for maintaining a log for all the actions done through code.
Or else, we manually need to write our own cod for logs.?
Any information on this is very helpful.
Thank you,
Praveen
Logs(Log File)
Re: Logs(Log File)
See the Report class....
Here is a wee example, I use the .net StackTrace class so it outputs the class/method name too...
You can also do Report.Success(), Report.Failure(), Report.Warn(), Report.Debug etc...
Here is a wee example, I use the .net StackTrace class so it outputs the class/method name too...
You can also do Report.Success(), Report.Failure(), Report.Warn(), Report.Debug etc...
Report.Setup(ReportLevel.Info, currentTestReportName, true);
LogInfo("information!!!");
Report.End();
public static void LogInfo(string info)
{
StackTrace stackTrace = new StackTrace();
string location = stackTrace.GetFrame(1).GetMethod().DeclaringType.Name + "::" + stackTrace.GetFrame(1).GetMethod().Name ;
Report.Info(location, info);
}
-
- Posts: 27
- Joined: Sat Aug 27, 2011 9:41 am
Re: Logs(Log File)
Thanks for your reply.
Can I have C # code please ...?
Can I have C # code please ...?
Re: Logs(Log File)
That is C# 

-
- Posts: 27
- Joined: Sat Aug 27, 2011 9:41 am
Re: Logs(Log File)
"StackTrace stackTrace = new StackTrace();
string location = stackTrace.GetFrame(1).GetMethod().DeclaringType.Name + "::" + "
This one is not working with ranorex...!
Please help me out.
I am new for C#.
string location = stackTrace.GetFrame(1).GetMethod().DeclaringType.Name + "::" + "
This one is not working with ranorex...!
Please help me out.
I am new for C#.
-
- Posts: 27
- Joined: Sat Aug 27, 2011 9:41 am
Re: Logs(Log File)
Hi Sdaly ,
It is working fine with;
System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace();
Thank alot buddy. It completely my mistake to over look the code . Sorry for that.
And keep helping me..........!!
It is working fine with;
System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace();
Thank alot buddy. It completely my mistake to over look the code . Sorry for that.
And keep helping me..........!!

Re: Logs(Log File)
Where do I use this code on .cs file, like I am calling method enterEmailAddress(); should i use the below code before calling the method or any advise please.
Report.Setup(ReportLevel.Info, currentTestReportName, true);
LogInfo("information!!!");
Report.End();
public static void LogInfo(string info)
{
StackTrace stackTrace = new StackTrace();
string location = stackTrace.GetFrame(1).GetMethod().DeclaringType.Name + "::" + stackTrace.GetFrame(1).GetMethod().Name ;
Report.Info(location, info);
}
Report.Setup(ReportLevel.Info, currentTestReportName, true);
LogInfo("information!!!");
Report.End();
public static void LogInfo(string info)
{
StackTrace stackTrace = new StackTrace();
string location = stackTrace.GetFrame(1).GetMethod().DeclaringType.Name + "::" + stackTrace.GetFrame(1).GetMethod().Name ;
Report.Info(location, info);
}
Tipu