GenericExtendedActions.Audit( AppInfo.GetAppInfo().OsContext, <Message>, <ModuleName> );
Thanks for making this information available, it is really useful. I would just like to add that the Audit method is deprecated. we should use the LogMessage method instead.
The updated version is:
GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, <Message>, <Module Name>);
GenericExtendedActions.audit(AppInfo.getAppInfo().getOsContext(), "Module", "Message")
using OutSystems.HubEdition.RuntimePlatform.Log; Then in your extension (replace "Mandrill" with the name of the extension!):
private void LogError(WebException e)
{
var fullMessage = "MESSAGE: " + e.Message;
using (var streamReader = new StreamReader(e.Response.GetResponseStream()))
fullMessage += "\nRESPONSE: " + streamReader.ReadToEnd();
}
fullMessage += "\nDATA:";
foreach (var key in e.Data.Keys)
fullMessage += "\n" + key + ": " + e.Data[key];
LogError(fullMessage);
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(), "Mandrill");
private void LogError(string message)
if (message.Length <= 2000)
AppInfo.GetAppInfo().OsContext.Session.UserId, message, "", "Mandrill");
else
for (var currentPosition = 0; currentPosition <= message.Length - 1; currentPosition += 2000)
var endPosition = Math.Min(message.Length - currentPosition, currentPosition + 2000);
AppInfo.GetAppInfo().OsContext.Session.UserId, message.Substring(currentPosition, endPosition), "", "Mandrill");
Worked like a treat ! thanks
Excuse my ignorance but I'm still finding my way in Outsystems, where do you find the error logs as they're not appearing in Service Center?
Sienna wrote:
This doesn't log to "errors" it logs to "general".
J.Ja
Apologies for the delay in replying, I was busy working on other things.
I still can't see anything under Monitoring>General either. I have added your code and...
GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, "MyTestComment", "MyVoidName");
What am I missing?
Ok cancel that, it has now mysteriously appeared and I've no idea why but not going to complain lol.
Is this still working? I can't see anything on General Tab.
It works for me currently. Have you implemented the necessary code above in your solution?
Using this code:
For me, nothing appears on General Tab...
Try adding these as well....
private void LogError(WebException e) { var fullMessage = "MESSAGE: " + e.Message; using (var streamReader = new StreamReader(e.Response.GetResponseStream())) { fullMessage += "\nRESPONSE: " + streamReader.ReadToEnd(); } fullMessage += "\nDATA:"; foreach (var key in e.Data.Keys) { fullMessage += "\n" + key + ": " + e.Data[key]; } LogError(fullMessage); } 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(), "AsposeWordIntegration"); } private void LogError(string message) { if (message.Length <= 2000) { ErrorLog.StaticWrite(DateTime.Now, AppInfo.GetAppInfo().OsContext.Session.SessionID, AppInfo.GetAppInfo().eSpaceId, AppInfo.GetAppInfo().Tenant.Id, AppInfo.GetAppInfo().OsContext.Session.UserId, message, "", "AsposeWordIntegration"); } else { for (var currentPosition = 0; currentPosition <= message.Length - 1; currentPosition += 2000) { var endPosition = Math.Min(message.Length - currentPosition, currentPosition + 2000); ErrorLog.StaticWrite(DateTime.Now, AppInfo.GetAppInfo().OsContext.Session.SessionID, AppInfo.GetAppInfo().eSpaceId, AppInfo.GetAppInfo().Tenant.Id, AppInfo.GetAppInfo().OsContext.Session.UserId, message.Substring(currentPosition, endPosition), "", "AsposeWordIntegration"); } } }
So...
Now doing this:
GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, "Who you gonna call?", "Ghostbusters!");
crashes with this error:
Object reference not set to an instance of an object.
Awesome!
I'm on Version 10.0.1014.0 of the platform, if that helps.
Hi Carlos,
Are you calling the Action in the Extension from a Module, or are you trying to use it in Visual Studio itself, in a test project of some sorts? The "Object reference" error is probably because GetAppInfo() returns a null object, which would be the case when you call it outside a Module.
I am, yes.
Luckily I managed to figure out what was wrong with the extension (pro tip: if you're calling a web service, make sure you use the correct endpoint ??) so I'm OK for now.
Also, I didn't even know you could use the OutSystems references outside of an extension. To be fair, these days creating extensions is mostly only needed for quirky stuff like ancient SOAP web services that don't really follow the standards, so I'm definitely not an expert at it.