cancel
Showing results for 
Search instead for 
Did you mean: 

Generating SumoLogic friendly Text log file (or informative XML files)

SOLVED
shantlk
Contributor

Generating SumoLogic friendly Text log file (or informative XML files)

Hi,

We are planning to automate our test runs and reporting.

We will be running our test in commandline and exporting the logs.

We will be using SumoLogic to display all our logs.

SumoLogic needs the logs to be in.log format. (or XML)

I have used to /ErrorLog:"C:\ErrorLogs\ProjErrors.log" command to generate an error file whenever there is any error.

However, Sumologic is unable to read this log file as it does not contain timestamp.

Appreciate if someone can help me how to get timestamp on the errorlog.

Also if I can generate any other error file(.log or .xml format) which would be able to give a proper informative log in the SumoLogic dashboard, that would be great !

 

Thanks a lot in advance

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: Generating SumoLogic friendly Text log file (or informative XML files)

Hi,

 

https://support.smartbear.com/testcomplete/docs/testing-with/log/working-with/from-tests.html might provide some useful info/code samples.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

8 REPLIES 8
tristaanogre
Community Hero

Re: Generating SumoLogic friendly Text log file (or informative XML files)

Rather than generating from a commandline, consider using Log.SaveResultsAs.  Add that code to the very end of your project and indicate to save the file as XML.  Reference. https://support.smartbear.com/testcomplete/docs/testing-with/log/working-with/exporting/about.html#x...


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
shantlk
Contributor

Re: Generating SumoLogic friendly Text log file (or informative XML files)

Hi Robert,

Thank you for your suggession. But I have already tried that. I faced following issues with that.

1) The generated XML files does not contain valueable information such as errors.

2) Even if I give a different log file name, it does not add the logs of the next run to the same folder. ( I need all the logs to be saved in the specified folder after each run)

3) The XML file does not contain timestamp (SumoLogic requires timestamp to display the details properly in dashboard)

 

Appreciate if an alternate method can be suggested.

Thank you

 

baxatob
Community Hero

Re: Generating SumoLogic friendly Text log file (or informative XML files)

Hi,

 

The standard TestComplete log file contains datestamp, but in Unix (Epoch) format. So you should perform some conversions to use it for your needs. 

 

Anyway your requirement looks like rather complex task to the moment. You need a script, which will find a proper xml data among all log files, parse data, make all required conversions, make correct structure etc...

AlexKaras
Community Hero

Re: Generating SumoLogic friendly Text log file (or informative XML files)

Hi,

 

https://support.smartbear.com/testcomplete/docs/testing-with/log/working-with/from-tests.html might provide some useful info/code samples.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

tristaanogre
Community Hero

Re: Generating SumoLogic friendly Text log file (or informative XML files)

As for containing errors, the Log.SaveResultsAs generates ALL the data that is in the TestComplete log.  So, if there is an error logged, it will contain that error.  Again, you will need to parse the information out as it doesn't show up "neat" as strictly errors.  You will need to look for that information.  @AlexKaras link might help with that.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
shantlk
Contributor

Re: Generating SumoLogic friendly Text log file (or informative XML files)

Hi Alex,

Thank you for the link. I was able to generate a customized log by modifying the given sample code.

Thanks a lot everyone for their help too.

 

below is a peice of my script which I used to get the timestamp and the log message for each row of the test log.

 

 # Checks the data type of the log data
      if LogDataType == ldtTable:
        # Obtain the total number of rows in the dataset
        Num = DataSet.RowCount
        for i in range(0, Num):
          Row = DataSet.Rows[i]
          # Obtai the time of the current row & write this to the log file
          TimeVal = Row.ValueByName["Time"]
          ExportFile.WriteLine(aqConvert.VarToStr(TimeVal))
          # Obtain the message of the current row & write this to the log file
          MsgVal = Row.ValueByName["Message"]
          ExportFile.WriteLine(aqConvert.VarToStr(MsgVal))

 

AlexKaras
Community Hero

Re: Generating SumoLogic friendly Text log file (or informative XML files)

@shantlk:

 

Hi,

 

Thank you for sharing your solution here. Hopefully, it will help others who may have similair question.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
shantlk
Contributor

Re: Generating SumoLogic friendly Text log file (or informative XML files)

Thanks everyone.

I also managed to capture the type of the message to send to sumologic. Not sure if this is the best way to do it. But works very well for me. Thought of sharing so it might be helpful for someone.

 

# Checks the data type of the log data
      if LogDataType == ldtTable:
        # Obtain the total number of rows in the dataset
        Num = DataSet.RowCount
        for i in range(0, Num):
          Row = DataSet.Rows[i]
          # Obtain the time of the current row & write this to the log file
          TimeVal = Row.ValueByName["Time"]
          ExportFile.WriteLine(aqConvert.VarToStr(TimeVal))
                
           # Obtain the type of the current row & write this to the log file
          TypeVal = Row.ValueByName["Type"]
          if (TypeVal == 822415382):
             Type = "Event"
          elif (TypeVal == 990187621):
             Type = "Message"
          elif (TypeVal == 18446744073223342617):  
             Type = "Checkpoint"
          elif (TypeVal == 1174736231):  
             Type = "Warning"
          elif (TypeVal == 923080487):  
             Type = "Error"  
          ExportFile.WriteLine(Type)  

 

          # Obtain the message of the current row & write this to the log file
          MsgVal = Row.ValueByName["Message"]
          ExportFile.WriteLine(aqConvert.VarToStr(MsgVal))

 

--------------------------------------------

So the output looks something like this:

 

28/08/18 15:29:31
Event
The process "firefox" was closed.
28/08/18 15:29:32
Message
Mozilla Firefox was launched.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors