Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Printing to a log
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
I need to print a message to the log. Have tried write, print, msgbox. I don't want it coming up as a pop up. Want it to print to the log. Thanks in advance.
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Using print will not give any pop up. It will send the message to print log.
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
You can minimize it through coding and also later export its result to text file.
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Use Reporter Statement if you want to see in log

Reporter.ReportEvent 0, "Object Name", "write the message which you want to see in the result"

0 for micpass
1 for micwarning
2 for micfail
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks Pradeep. That worked well.
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
Below is the code for creating the log file,
It will update the date and time followed by the message. Later it can be used for analysis.

'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Function to write a log file>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'This function is used to create logs
'The log file will be stored with filename as "Logfile.log" by default
'If the log file is present in the path specified, it will be updated else it will be created.
'StrTitle -> Used to give the Title for the log. Eg: Test
'StrMessage -> The message which needs to be sent
Usage: Writetolog("Test", "This is a test")
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Code:
Function Writetolog(StrTitle, StrMessage)
Dim objFS, Logfilepath, ObjFile
Set objFS = CreateObject("Scripting.FileSystemObject")
Logfilepath = Pathofthefolderwherelogfileshouldbestored & "Logfile.log" 'Enter the log file path here
If objFS.FileExists(Logfilepath) Then
        Set objFile = objFS.OpenTextFile(Logfilepath,8,False)
    Else
        objFS.CreateTextFile Logfilepath,True
        Set objFile = objFS.OpenTextFile(Logfilepath,8,False)
End If

objFile.Write "[" & Date &"]" & "[" & Time & "][" & StrTitle &"][" & StrMessage & "]" &vbcrlf

objFile.Close
Set objFile = Nothing
Set objFS = Nothing
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hope this helps.

Let me know in case of any questions.

Thanks,
Elango
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Grab multiple line data from log file haziqwebs 0 1,792 10-19-2016, 01:28 PM
Last Post: haziqwebs
  How to print value in QTP Log using .vbs kalyaniR 1 3,366 10-25-2013, 04:32 PM
Last Post: ssvali
  To view log files in QTP sheetal 5 16,759 10-08-2013, 02:27 PM
Last Post: Gurpreet
  Hep to create yahoo log in function. jinnah1978 1 2,851 02-23-2012, 10:24 AM
Last Post: inborntester
  Log in problem JeanFrederique 1 2,071 10-20-2009, 01:38 PM
Last Post: Tarik Sheth

Forum Jump:


Users browsing this thread: 2 Guest(s)