Retrieving and Processing the RuleExecutionLog

  • Updated

Prerequisites: A valid RuleSession and Entity.
Namespaces: InRule.Runtime
Classes: RuleSession, Entity
References: InRule.Runtime.dll, InRule.Common.dll

Retrieving RuleExecutionLog from RuleSession.ApplyRules

// Apply rules and capture RuleExecutionLog
RuleExecutionLog executionLog = ruleSession.ApplyRules();

Retrieving RuleExecutionLog from Entity.ExecuteRuleSet

// Execute explicit RuleSet and capture RuleExecutionLog
RuleExecutionLog executionLog = entity.ExecuteRuleSet("CalculatePaymentSchedule");

Processing the RuleExecutionLog

The following method will take a RuleExecutionLog as a parameter and return a string with the text from all of the messages separated by line breaks.

public string GetExecutionLogText(RuleExecutionLog executionLog)
{
  // Spin through all of the messages in the RuleExecutionLog and append to a StringBuilder
  StringBuilder sb = new StringBuilder();
  foreach (LogMessage message in executionLog.AllMessages)
   {
       sb.Append(message.Description + Environment.NewLine);
   }
  // return string
  return sb.ToString();
}

See the Implementation Guide for more details.

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.