◷ 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:
- Automatically (Using IRuntimeEngine.EnableFullLog)
- Manually (Using FlexRule.Events.RuntimeEvents)
Here is the list of events that can be captured:
|Name||When is raised?|
|CriteriaEvaluated||logic of a rule is evaluated|
|RanActions||Actions of a rule are executed because the criteria are met|
|RanAlternateActions||Actions of a rule are executed because the criteria are not met|
|ConditionEvaluated||Condition of a rule is evaluated|
|RunningReferencedLogic||Referenced logic of higher level is about to run|
|CriteriaEvaluating||criteria 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):  Destination: (Result=false) R2 (Passed=True): Conditions (Count=3):  Destination: (Result=true)  Age: (Result=true)  Is Friday or Monday: (Result=true) R3 (Passed=False): Conditions (Count=3):  Destination: (Result=true)  Age: (Result=true)  Is Firday or Monday: (Result=false) R4 (Passed=False): Conditions (Count=1):  Destination: (Result=false) R5 (Passed=False): Conditions (Count=1):  Destination: (Result=false) R6 (Passed=False): Conditions (Count=2):  Destination: (Result=true)  Age: (Result=false) R7 (Passed=False): Conditions (Count=2):  Destination: (Result=true)  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.
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.
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.
- The file name can be viewed.
- Passed rules are shown in Green color
- If a rule with multiple expressions failed, the expressions that passed can be seen.
- 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.