Read Logs
#
Read logsTo read existing logs you will need to make a TLS request to the OpenHIM API for the below method and endpoint.
By default the logs with level info and above for the last 5 minutes are returned. The logs will be returned as an ordered array. A maximum of 100 000 log messages are returned (hint: use pagination).
The following filters are available:
from
- an ISO8601 formatted date to query from. Defaults to 5 mins ago.until
- an ISO8601 formatted date to query until. Defaults to now.start
- a number n: the log message to start from, if specified the firstn
message are NOT returned. Useful along with limit for pagination. Defaults to 0.limit
- a number n: the max number of log messages to return. Useful along withstart
for pagination. Defaults to 100 000.level
- The log level to return. Possible values aredebug
,info
,warn
anderror
. All messages with a level equal to or of higher severity to the specified value will be returned. Defaults toinfo
.
#
ExampleNote: In the examples below, we are using the token authentication type to authenticate requests
Before we can send our request to the OpenHIM API we need to ensure that we construct our valid HTTP headers to successfully authenticate with the OpenHIM API.
- NodeJS
- Bash
Copy the below code at the bottom of your nodejs script that handles the authentication of the OpenHIM headers as described in the authentication section.
Replace the openhimOptions
values with the correct implementation details
Ensure that you have created your bash script to construct the HTTP authentication headers and send the request to the OpenHIM API as described in the authentication section.
Execute the below command in your terminal where the file is located with the required arguments. Replace the placeholder arguments with the correct implementation details.
The response status code will be 200
if successful.