Use Case 6: Use the System Event Logs for Logging Method Failure
In this section, we will see how to log any method failure error message in ARAS OOTB System Event Logs.
Use Case: "As an administrator, want to see the end user method execution failed error in system to debug and identify the root cause of the error"
Steps to be followed are:
Add New Event Type in List
Step 1: Navigate to Administration > Lists > SystemEventType
Step 2: Add Event type you want to log (Example : OnAfterAdd)
Add New System Event
Step 3: Navigate to Administration > System Events > System Events
Step 4: Create New > Add New System Events > Select Event Type and Save
Add New System Event Log Descriptor
Step 5: Navigate to Administration > System Events > System Event Log Descriptor
Step 6: Create New > Add New System Event Log Descriptor > Select Event Type and Save
Create Story_FailedMethod_SystemLog Method
Step 7: Create new Server Side method (Method Name: Story_FailedMethod_SystemLog)
Innovator inn = this.getInnovator();
string eventType = this.getProperty("eventType");
string methodName = this.getProperty("methodName");
string errorMessage = this.getProperty("errorMessage");
string userID = inn.getUserID();
CCO.SystemEventLogger.CreateSystemLogRecord(eventType,methodName,userID,errorMessage);
return this;
Logging the Error Message in System Event Logs in Server Side
Step 8: Add below lines of code in any sever method you want to log
Innovator inn = this.getInnovator();
var addSystemLogs = inn.newItem("Method", "Story_FailedMethod_SystemLog");
addSystemLogs.setProperty("eventType","onAfterAdd");
addSystemLogs.setProperty("methodName","Story_FailedMethod_SystemLog_CS");
addSystemLogs.setProperty("errorMessage","Throwing Error from C# Method");
addSystemLogs = addSystemLogs.apply();
return inn.newError("Throwing error after creating System Log Record from C# Method");
Logging the Error Message in System Event Logs in Client Side
Step 9: Add below lines of code in any client side method you want to log
var addSystemLogs = aras.newIOMItem('Method', 'Story_FailedMethod_SystemLog');
addSystemLogs.setProperty("eventType","onAfterAdd");
addSystemLogs.setProperty("methodName","Story_FailedMethod_SystemLog_JS");
addSystemLogs.setProperty("errorMessage","Throwing Error from JavaScript Method ");
addSystemLogs = addSystemLogs.apply();
return aras.AlertError("Throwing error after creating System Log Record from JavaScript Method");
Note: This logging can be done only on standard ARAS server events. In case a method is called from another server method / client method, then it is possible to log the event but the event type in the log will be any standard ARAS server events. You can hide the Event Type in System Events form and add all needed information in Comments.
Comments
Post a Comment