2782
Views
15
Comments
Setting Logging Level of a REST API

Since this topic comes up every once in a while, I decided to write a quick guide aimed at the beginner level on how to set the Logging Level of an Exposed or Consumed REST API to aid in debugging. This can be useful in case you need to see what's going on when e.g. the server reports an unhelpful "500 Internal Server Error", and you need to see what's going on.

1. Increase Logging Level

  1. Open Service Center of your server and log in.
  2. Chose "Factory" and "eSpaces" from the menu, and search for the right eSpace (the one consuming or exposing the REST API).
  3. Click the "Integrations" tab.
  4. Click on the name of the REST API below "Consumed REST APIs" or "Exposed REST APIs".
  5. Set "Logging Level" to "Full" (there's also "Troubleshoot", but I'm not sure about the differences with "Full").

2. Check the logging

  1. After you have consumed the REST API (either by running the application that consumes it, or running an application (or e.g. Postman) that consumes your REST API, again open Service Center (if it's not already open), en chose "Monitoring" and "Integrations" from the menu.
  2. Optionally filter for the eSpace that consumed or exposed the REST API.
  3. Click "Detail" (the very last column) after the entry you're interested in (note that "Detail" will not appear if you haven't increased the Logging Level).
  4. On the page that appears you can see what has been sent, and what has been replied. If there's more than about a page it's cut off, and you can press the "Download HTTP Trace" button to get a text file with the full trace. Note that in case of binary content, it will be encoded in Base64; to decode it google for "decode base64" and you'll find online tools to decode the data.

That's about it. In case of errors, look for signs that there's something wrong, e.g. missing data, missing authentication headers, malformatted data, etc. Note that by default, the Platform doesn't send data that has the default value, so be aware that depending on the values of the data you send, not everything may appear (which could also be the source of a problem if an external REST API expects this data anyway).

Davidk
Rank: #0

Very cool... thanks.

It really helpful 

Thanks

Rank: #244

Kilian Hekhuis wrote:

Since this topic comes up every once in a while, I decided to write a quick guide aimed at the beginner level on how to set the Logging Level of an Exposed or Consumed REST API to aid in debugging. This can be useful in case you need to see what's going on when e.g. the server reports an unhelpful "500 Internal Server Error", and you need to see what's going on.

1. Increase Logging Level

  1. Open Service Center of your server and log in.
  2. Chose "Factory" and "eSpaces" from the menu, and search for the right eSpace (the one consuming or exposing the REST API).
  3. Click the "Integrations" tab.
  4. Click on the name of the REST API below "Consumed REST APIs" or "Exposed REST APIs".
  5. Set "Logging Level" to "Full" (there's also "Troubleshoot", but I'm not sure about the differences with "Full").

2. Check the logging

  1. After you have consumed the REST API (either by running the application that consumes it, or running an application (or e.g. Postman) that consumes your REST API, again open Service Center (if it's not already open), en chose "Monitoring" and "Integrations" from the menu.
  2. Optionally filter for the eSpace that consumed or exposed the REST API.
  3. Click "Detail" (the very last column) after the entry you're interested in (note that "Detail" will not appear if you haven't increased the Logging Level).
  4. On the page that appears you can see what has been sent, and what has been replied. If there's more than about a page it's cut off, and you can press the "Download HTTP Trace" button to get a text file with the full trace. Note that in case of binary content, it will be encoded in Base64; to decode it google for "decode base64" and you'll find online tools to decode the data.

That's about it. In case of errors, look for signs that there's something wrong, e.g. missing data, missing authentication headers, malformatted data, etc. Note that by default, the Platform doesn't send data that has the default value, so be aware that depending on the values of the data you send, not everything may appear (which could also be the source of a problem if an external REST API expects this data anyway).

It's really a valuable info..Thanks for sharing!!

Sachin


Rank: #134

Great stuff @kilian sir!!

Nice contribution!! Good Work!

Rank: #3894

Hi Kilian,

Thanks for this post!

May I know what performance issue will be caused by changing the Logging level to "Full"?


mvp_badge
MVP
Rank: #2

None, really. It's not adviced in production if you have large volumes of REST calls, and/or very large payloads, but on development and test you're pretty safe.

Rank: #9534

I cannot find eSpaces area now, 1/11/2019. It seems the interface design is changed

mvp_badge
MVP
Rank: #2

Yes, it was renamed "Modules" in version 11, thanks Daniël for pointing it out. Unfortunately, I can't edit the original post.

Thank you so much for sharing knowledge.

Rank: #535

Kilian Hekhuis wrote:


2. Check the logging


4. On the page that appears you can see what has been sent, and what has been replied. If there's more than about a page it's cut off, and you can press the "Download HTTP Trace" button to get a text file with the full trace. Note that in case of binary content, it will be encoded in Base64; to decode it google for "decode base64" and you'll find online tools to decode the data.

Thanks for the valuable info, Kilian! That part about downloading HTTP trace is also important as the inner exception is usually not visible in the truncated error message in Service Center.


mvp_badge
MVP
Rank: #2

You're most welcome Ozan! Happy coding :)

Rank: #238

Stumbled upon this post while wondering the difference between "Troubleshoot" and "Full".

Here are the details from OutSystems documentation:

(https://success.outsystems.com/Documentation/11/Developing_an_Application/Troubleshooting_Applications/Troubleshoot_Service_Actions_Using_Logs#how-to-change-the-logging-detail-level-for-service-action)

The available logging levels for Service Action requests are the following:

Default
All requests are logged including some basic information (like the date and time of the request). No details regarding errors, request headers or payloads are logged.
Troubleshoot
On top of the information kept by the Default level, error details are also logged. Click on the "Error" link displayed on the right to get more details about the error.
Full
On top of the information kept by the Troubleshoot level, request headers and payloads are also logged. Click on the displayed "Error" link or, if there's no error, click on the "Details" link to obtain detailed logging information.

It seems to say "Troubleshoot" has "Full" logging for errors and "Default" for anything else.