Forum Discussion

anatar02's avatar
anatar02
Contributor
12 years ago

How to get the event logs into the file?

Hi, 



i would like to get all events log into any of the log file. but i could not find the way to do this...so can you please some one advice me on the same... I am using C# scripting
  • If I understand your request correctly, one way to handle this would be to define a GeneralEvent for "OnLogEvent" and have it output the Message text and Additional text fields to your secondary test file.



    I'm familar mostly with VBscripting but it should give you the gist.



    Sub GeneralEvents_OnLogEvent(Sender, LogParams)

      Dim sPath

      Dim FileInf

      Dim TimeStamp

      Dim MsgTxt

      Dim AddTxt

      'Prep for logging to file

      sPath = ProjectSuite.Variables.logPath

      Set FileInf = aqFileSystem.GetFileInfo(sPath)

      TimeStamp = aqConvert.DateTimeToFormatStr(aqDateTime.Now,"%m/%d/%Y %H:%M:%S")

      'Get the content of Message Text

      MsgTxt = LogParams.MessageText

      'Get the content of Additional Text

      AddTxt = LogParams.AdditionalText

      'Write these values to the log file

      Call FileInf.WriteToTextFile(TimeStamp & vbTab & MsgTxt & vbTab & AddTxt & vbCrlf, aqFile.ctANSI, False)

    End Sub
  • If I understand your request correctly, one way to handle this would be to define a GeneralEvent for "OnLogEvent" and have it output the Message text and Additional text fields to your secondary test file.



    I'm familar mostly with VBscripting but it should give you the gist.



    Sub GeneralEvents_OnLogEvent(Sender, LogParams)

      Dim sPath

      Dim FileInf

      Dim TimeStamp

      Dim MsgTxt

      Dim AddTxt

      'Prep for logging to file

      sPath = ProjectSuite.Variables.logPath

      Set FileInf = aqFileSystem.GetFileInfo(sPath)

      TimeStamp = aqConvert.DateTimeToFormatStr(aqDateTime.Now,"%m/%d/%Y %H:%M:%S")

      'Get the content of Message Text

      MsgTxt = LogParams.MessageText

      'Get the content of Additional Text

      AddTxt = LogParams.AdditionalText

      'Write these values to the log file

      Call FileInf.WriteToTextFile(TimeStamp & vbTab & MsgTxt & vbTab & AddTxt & vbCrlf, aqFile.ctANSI, False)

    End Sub
  • mc_stilet's avatar
    mc_stilet
    New Contributor
    If I understabd you correctly you just need to select "Event" checkbox on the log file. Otherwise you should create event handler function and call it when event happens.
  • Yes...That is the option displaying the logs but my requirement is logging all the default logs into a file!!! 
  • Thanks Boss for your invaluable reply !!!



    This is what, i was looking for !!!



    I not yet converted the function to C# as first i wanted understand and clarified some doubts? Hope u would help me even through my doubt is useless 



    Could you please tell me what is the value i need to pass throw following parameters 

    Sender, LogParams