Events at Runtime

◷ Reading Time: 5 minutes


FlexRule Runtime is event driven. That means you can capture details of what is happening during rules execution. Namespace FlexRule.Events has all related types for this behaviour. There are two ways of capturing the events:

  1. Automatically (Using IRuntimeEngine.EnableFullLog)
  2. Manually (Using FlexRule.Events.RuntimeEvents)


Here is the list of events that can be captured:

NameWhen is raised?
CriteriaEvaluatedlogic of a rule is evaluated
RanActionsActions of a rule are executed because the criteria are met
RanAlternateActionsActions of a rule are executed because the criteria are not met
ConditionEvaluatedCondition of a rule is evaluated
RunningReferencedLogicReferenced logic of higher level is about to run
CriteriaEvaluatingcriteria of a rule is about to be evaluated



When on RuntimeEngine.EnableFullLog is set to true, it captures all the events for execution. Then RuntimeResult.ConclusionLog can be used to retrieve a generated execution log based on raised events. Below is a sample of a conclusionLog:

Document: discount percentage
 R1 (Passed=False): 
 Conditions (Count=1):
 [1] Destination: (Result=false)

 R2 (Passed=True):
 Conditions (Count=3):
 [1] Destination: (Result=true)
 [2] Age: (Result=true)
 [3] Is Friday or Monday: (Result=true)

 R3 (Passed=False):
 Conditions (Count=3):
 [1] Destination: (Result=true)
 [2] Age: (Result=true)
 [3] Is Firday or Monday: (Result=false)

 R4 (Passed=False):
 Conditions (Count=1):
 [1] Destination: (Result=false)

 R5 (Passed=False):
 Conditions (Count=1):
 [1] Destination: (Result=false)

 R6 (Passed=False):
 Conditions (Count=2):
 [1] Destination: (Result=true)
 [2] Age: (Result=false)

 R7 (Passed=False):
 Conditions (Count=2):
 [1] Destination: (Result=true)
 [2] Age: (Result=false)


When you don’t need a full log, and you are just looking for some specific events, then RuntimeEngine.Events can be set manually to any of the events mentioned above. After execution is finished all of the events RuntimeResult.Events will have all the collected execution events:

Custom Build Reports

There might be a need to create custom reports based on specific layouts, and formats, etc. This can be done by creating applications and collecting Runtime execution events and finally, putting the events’ information back together as a report to present in the desired format or layout.

FlexRule Runtime provides a FlexRule.Events namespace to manage and access the events. Your application can subscribe to events using the RuntimeEvents.Register method, which allows registering for specific events.
The events can be aggregated to create custom reports. Events have a semantic relationship as a child-parent relationship. To understand and navigate this relationship, out-of-the-box the event aggregation is provided by Report Elements in FlexRule Runtime.

FlexRule Designer

Debugger Log

When running rules in FlexRule Designer, EnableFullLog is set to true and the result of the conclusion log can be seen in the output window under Debugger Log section.

Event Viewer

You can use the event viewer in FlexRule Designer to see the step-by-step process of executed logics.

As the first step, run your project.
You can use of the options, Run, Run with JSON Composer or Logic Run Template. You will not see the events if you choose to debug.

Once you finish the execution, events can be seen under the Parameters window.

If you click on $events and then click on the Data Vewer, it will open the Events Viewer window.

Event Viewer shows a detailed view of the logic execution.

  1. The file name can be viewed.
  2. Passed rules are shown in Green color
  3. If a rule with multiple expressions failed, the expressions that passed can be seen.
  4. Failed rules are shown in Yellow.

You can also search in the events.
After searching, if you click on a logic in search results and remove the filter, it will show the hierarchy of the selected logic.


Have a look at the Airline Discount Program sample.

Updated on February 12, 2020

Was this article helpful?

Related Articles