How to audit from an extension?

How to audit from an extension?

Does anyone knows how to audit from an extension?

Thank you.
Hi Mário,

You can simply use this statement: GenericExtendedActions.Audit(AppInfo.GetAppInfo().OsContext, "AUDIT MESSAGE", "MODULENAME");

I believe someone else has published a more detailed post about this...but can't find it. So, here's the straight answer, anyway.


Pedro Gonçalves
I've been searching for how to log the errors of an extension I'm working on a this partially solves my problems.

The issue is: What if want to log an exception into the error log and not the general log?

This is where it really belongs in terms of semantics and its where I need to place it.

Thanks in advance for your support.

All the best,
Pedro Oliveira
Hi Pedro,

This is an undocumented feature but you can use:

using OutSystems.HubEdition.RuntimePlatform.Log; ...
private void LogError(Exception e) {
ErrorLog.StaticWrite(DateTime.Now, AppInfo.GetAppInfo().OsContext.Session.SessionID,
AppInfo.GetAppInfo().eSpaceId, AppInfo.GetAppInfo().Tenant.Id,
AppInfo.GetAppInfo().OsContext.Session.UserId, e.Message, e.ToString(), "My Message here");

I hope this helps you.
Thanks André!

This does work as expected. I will use this in my extension.

All the best,
If you're wondering how to use the GenericExtendedActions it in java.... here it goes

GenericExtendedActions.audit(AppInfo.getAppInfo().getOsContext(), "AUDIT MESSAGE", "MODULENAME");