Hello everyone,
I’m currently working on creating custom logging functionality for several reasons:
I’ve created an entity called APILogs to handle the logging:
Entity: APILogs
The goal is to log the entire API call in one record, so both the request and response are stored together.
Here’s my approach so far:
The challenge I’m facing is that there’s no way to output a unique identifier from the OnBeforeRequest action that can be retrieved later in the OnAfterRequest action. This means I can’t link the response back to the corresponding request.
I’d like to implement this in a way that the logging functionality can be reused as a service action across all my APIs, with minimal input configuration required for each API.
Does anyone have any suggestions or best practices to overcome this challenge? Your insights would be greatly appreciated!
Thank you in advance!
Why would you want to log again what is already logged?
You can access the OutSystems logs and build a UI on top of it without replicating the logs.
As stated in my question:
Yes and I wrote, write the app (build a UI on top) of the existing log data, to avoid duplicating logging. With the app I suggest to write you achieve to provide insights for non-developers or users who don’t have access to standard logs, enabling them to see which API calls went wrong. without having a copy of all the logging in another table.
Further considerations, the OutSystems logs are having a lot of records, there is a reason why the log tables rotate per week. If you write all the logging to your entity, you need to provide similar setup or with a week or so your application will have serious performance degradation.
In O11 it wouldn't be needed but ODC offers a less complete Logging system as far as i am concerned. O11 would have the tools to build this but since i am trying to do this in ODC it seems way harder.
I was confused as you mentioned this in your post:
Yes I agree, with ODC it is a complete different story, no public API currently exists to access the logging and use it in applications. It is douable, we did it on a project to extra logs into external logging system, but you have to dive into the internal API calls that the ODC portal makes to show logs. Once you understand that not-public API, you can use it for your benefit. It avoids double logging, but has a dependency on internal working of ODC.
In that case your solution is an acceptable workaround, until OutSystems supports a public API on the logs of ODC.
But that is the issue at hand, i do not have a solution yet. I was also wondering if there was a way to connect to existing logs or something just so i can make an overview page within the application.