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
  • ebodien's avatar
    12 years ago
    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