OutSystems Platform — Auditing 101 — Part II

João Heleno
4 min readOct 3, 2018

Long time, no see… It’s been a while since I wrote Part I. If you are discovering the OutSystems Platform, I suggest you read it first.

The AsynchronousLogging API is one of many API that OutSystems exposes for you to extend the functionality of your applications. It becomes handy when you need to register information in an asynchronous way.

❗️ All the information provided to the API will be kept in a message queue and will be inserted in bulk in the database. In case of system failure pending messages will be lost.

Setup

Before starting make sure you have added the following producer modules in your application: PlatformRuntime_API and AsynchronousLogging.

To use the API reference these modules in your applications

LogError

The first API action is the LogError action. Nothing tricky here. Just fill in the Message and Detail inputs and you’re set. The Request_GetKey() function comes from the PlatformRuntime_API module.

👉 The messages saved using this action will appear in Service Center under Monitoring/Errors. Notice the Module name. It will help you filter the results.

LogRecord

The next action in the API is the LogRecord one. As the name suggests, you have to pass an Entity Record as an input. The beauty of this one is that you can use any kind of entity record. While writing this article I created a table called My_Log_Entity with three attributes. When using this action don’t forget to use ToObject() around the entity record.

❗️ If you try to pass a structure it won’t work.

👉 The messages saved with the LogRecord action will be saved in bulk in the specified table. You can use it to make your own errors page a la Service Center.

LogRequestEvent

The last one is LogRequestEvent. Of all the three actions this is the one that takes more inputs.

  • Request_GetKey() is from PlatformRuntime_API.
  • GetOwnerEspaceIdentifier is a built in action.
  • For the ApplicationKey and ApplicationName you will have to check the Application table. Use an aggregate to query data from this table in the (System) module.
LogRequestEvent action inputs.
  • RequestEventDetails is text in JSON format. Use the built in JSON Serialize action if you are using records or list already mapped in your application.

👉 The messages saved with LogRequestEvent will be saved in the Log_RequestEvent table. Deserialize the data in the EventDetails column to see what was logged.

⛔️ I tried using unformatted text in the RequestEventDetails input but the event was not saved. Somehow internally the platform must be validating if the format is JSON and if it’s not it exits gracefully.

❗️ From version 11 of the Platform this and other system logging views are available for consuming through the PlatformLogs module. Just like in the LogRecord action you will have to do your own screens/logic to see the information saved.

Full documentation available here.

Happy “logging”!

Dedicated to V. Mexia. 👊

Special thanks to Angie for proofing. 😺

--

--

João Heleno

Senior Consultant @ IG&H Platform Services | OutSystems MVP