locken
locken

Reputation: 11

Capturing server logs in Robot Framework

I was wondering if anyone knew of a way to capture application server logs for failing test cases in the Robot Framework?

Historically this might have been a big ask (connecting to the host machine & extracting the data from the log file itself...) but my team has been making use of Scalyr recently and I was hoping someone may have had some experience extrapolating the data from that.

For reference, we're using an in-house tool that records all of our test runs, including full failure messages from Robot Framework if a test falls over. Ideally, I'd like to see the 3 most recent log entries from the point the test case fails, reported alongside the failure message. The application servers under test are hosted on ec2 or centos instances.

If I can provide any other info that might help prompt an answer to this, please let me know!

Upvotes: 1

Views: 905

Answers (1)

forkdbloke
forkdbloke

Reputation: 1565

  1. Install robotframework-requests and
  2. perform the api call from RF.
  3. When i see the Scalyr doc , i see that there is Scalyr API where you can request for logs, all you need to do is use the below api to query the logs.
LOG QUERY
This method is used to retrieve events (log records). You can retrieve all events in a specified time range, or only events matching specific criteria.

URL
https://www.scalyr.com/api/query

Input
{
  "token":             "xxx",
  "queryType":         "log",
  "filter":            "...",
  "startTime":         "...",
  "endTime":           "...",
  "maxCount":          nnn,
  "pageMode":          "...",
  "columns":           "...",
  "continuationToken": "...",
  "priority":          "..."
}
token should be a "Read Logs" API token. 

Upvotes: 1

Related Questions