I’m currently working under a project which utilizes Red Hat Decision Manager as a runtime to provide a real-time decisions for banking. It is not a secret that it has drools
rule engine under the hood.
It’s possible to debug drools
applications using different tools and approaches, the one which is good from the visual side and pretty simple to analyze – is to ask the rules engine to create an execution log. Opposite to the regular debugging using your IDE (I prefer the Eclipse IDE
with the Drools
plugin installed) this approach gives you a full xml-based log, which will contain all events occurred during a session.
After the KieSession
instance is obtained it is possible to register a new KieRuntimeLogger
:
KKieSession kSession = kContainer.newKieSession("ksession-rules"); KieRuntimeLogger kieLogger = ks.getLoggers().newFileLogger(kSession, "log");
Also don’t forget to close the KieRuntimeLogger
instance:
kieLogger.close();
Run your drools
application and check your project folder. There you will find the log.log
(SIC!) file which contains a list of actions being invoked during the rule execution:
<object-stream> <org.drools.core.audit.WorkingMemoryLog> <version>6.1</version> <events> <org.drools.core.audit.event.ObjectLogEvent> <type>1</type> <factId>1</factId> <objectToString>ru.model.CustomerProfile@3e2822</objectToString> </org.drools.core.audit.event.ObjectLogEvent> </events> </org.drools.core.audit.WorkingMemoryLog> </object-stream>
If you’re also using drools plugin for Eclipse
you can open this file in the Audit
view (Window -> Show View -> Audit
):