Asynchronous Logging API - LogRequestEvent

Asynchronous Logging API - LogRequestEvent

  

Hi guys, 

2 questions:

  1. Am I using the right API/action here?
  2. How can I get the Application info dynamically?

I'm struggling with LogRequestEvent from the Asynchronous Logging API.  I'm trying to use this in place of the Audit action but to improve application efficiency and scalability.  Unfortunately I can't figure out how to get the Application info (key and Name).  I'm querying the System Table: 'Application'  but I can't figure out how to retrieve the value programmatically (based on the current module).  I'd thought perhaps the entry espaceId might help, but this value is null for all applications in the table.




Solution

Hi Steve,

I would stick to using Audits, if I were you. I don't think using LogRequestEvent has any advantages compared to Audit, since Audit is already asynchronous and you would have to build your own application to view the content registered with LogRequestEvent. Even if you do want to build your own custom logs, it would probably be easier to use LogRecord, if you're just logging information obtained server-side.

If I recall correctly, LogRequestEvent was thought out to log custom data obtained from the browser, through a REST service. In that use case you can obtain all the necessary keys using the outsystems.api.requestInfo javascript object, which exists in every screen.

Solution

oh. I was advised by outsystems guys to use the AsynchronousLog API instead of Audit to improve scalability.  there's only two functions of Asynch Log API which I can't seem to get to work.

That's interesting about the requestinfo api.  I read it and assumed it was only available at JS level, is that right?

If you are logging a large amount of data and need to search it, using Audit may not scale well, since everything is put into the same table and you won't be able to use custom segments for that information. In that case, you would have to build your own log search app and you could use Asynchronous Logging API's LogRecord, which has a straightforward use - just pass an entity record as an input and it will insert that record into that entity's matching table.


Indeed, outsystems.api.requestInfo is only available at JavaScript level.

Thanks for your help Joao, 

I was using the wrong Action.  i'm now using LogRecord.  BTW, Audit is Synchronous, not Asynchronous.  I'm now using LogRecord to push a Log_General record into the normal logging table, only asynchronously so I don't clog up the current thread. 

Steve Bramley wrote:

Thanks for your help Joao, 

I was using the wrong Action.  i'm now using LogRecord.  BTW, Audit is Synchronous, not Asynchronous.  I'm now using LogRecord to push a Log_General record into the normal logging table, only asynchronously so I don't clog up the current thread. 

I'm happy to help.

Where did you get the information that Audit is synchronous? I'm fairly certain the Audit action uses LogRecord to insert records into Log_General, unless your license doesn't include the "Asynchronous Logging" feature, which I think is a thing of the past; every license now includes that feature.

Here's a link to a forum post where João Portela, from OutSystems R&D, explains the licensing features that impact logging.

oh that's interesting.  My workplace signed up for OutSystems' Customer Success Program and during that, we were asked to use the Asynchronous Logging API rather than Audit because Audit was synchronous.  I'll double check.

Just a point to note:  It's Andre that says Audit is Asynchronous.  Joao just explains how to turn on asynchronous logging.

Thanks for your help regardless!