◷ Reading Time: 3 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 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 Firday 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 RuntimeEvents.Register method, which allows registering for specific events.
The events can be aggregated to create custom reports. Events have semantic relationship as a child-parent relation. 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.
Have a look at the Airline Discount Program sample.