Rule Execution Log Service

  • Updated


The Rule Execution Log Service allows application-level access to rule execution logs created during workflow execution.

At a high level, the process is as follows:

  1. A RuleExecutionLogService object is created and populated with the names of the ApplyRules activities it will monitor.
  2. The workflow is executed. Every time an ApplyRules activity is executed, the service checks to see if it is one that is being monitored. If so, its execution log is saved.
  3. After execution, the execution logs can be retrieved from the service and processed.

Creating and Populating the Service

To create and populate the service, simply create a RuleExecutionLogService object and populate its ActivityNames collection with the names of the activities to monitor. Once all activity names have been added, add the service to the workflow runtime via its AddService method.

using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
   RuleExecutionLogService logService = new RuleExecutionLogService();

Retrieving the Execution Logs

The rule execution log(s) may be retrieved during or after workflow execution. First, a reference to the service is required. This reference may already exist if the service was created in the same method; otherwise, a reference may be obtained via WorkflowRuntime’s GetService method. Once a reference has been obtained, a call to the GetExecutionLogs method, with the name of the activity as an argument, will return a collection of rule execution logs. The collection contains a rule execution log for every time it was executed during the course of the workflow.

   List<RuleExecutionLog> logs = logService.GetExecutionLogs("applyRules");
   RuleExecutionLog log = logs[0];
   Console.WriteLine("Total execution time: {0:n3} ms",

Difference between service and ApplyRules activity’s KeepRuleExecutionLog and LastRuleExecutionLog

The service’s primary function is to serve as a way to access rule execution logs from outside the context of an executing workflow. The ApplyRules activity’s KeepRuleExecutionLog property specifies whether the most recent rule execution log will be kept and available via its LastExecutionLog property, which may then be accessed by anything participating in the workflow. It is in no way related to the service.

Guidelines are as follows:

  • To access a rule execution log from within a workflow, use ApplyRules’ KeepRuleExecutionLog/LastRuleExecutionLog
  • To access one or more rule execution logs from outside the workflow, use the RuleExecutionLogService.

Was this article helpful?

0 out of 0 found this helpful



Please sign in to leave a comment.