I'm trying to figure out how I can create a Logger to log rule activations for my Template File code. I followed the examples to successfully create a Logger for DRL and Decision Table examples. Apparently, to create a Logger, the KnowledgeRuntimeLoggerFactory methods take a KnowledgeRuntimeEventManager type, which StatefulKnowledgeSession implements. But, for the Template File examples, the StatefulSession from the "unstable" drools-core *does not* implement this interface. SEE the code examples below - how do I create a Logger for my Template File code?
//#### DRL FILE & EXCEL FILE EXAMPLE FOR CREATING A SESSION AND FIRING THE RULES:// populate working memory KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(...[DRL or DTABLE resources]...); KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(); knowledgeBase.addKnowledgePackages(kbuilder.getKnowledgePackages()); // create session StatefulKnowledgeSession rulesSession = knowledgeBase.newStatefulKnowledgeSession(); KnowledgeRuntimeLogger rulesLogger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(rulesSession); //<<CREATE LOGGER! FactHandle factHandle = rulesSession.insert(myFact); // fire the rules rulesSession.fireAllRules();//#### TEMPLATE FILE EXAMPLE FOR CREATING A SESSION AND FIRING THE RULES:
// populate working memory ExternalSpreadsheetCompiler converter = new ExternalSpreadsheetCompiler(); InputStream spreadsheetStream = ... InputStream templateFileStream = ... String drl = converter.compile(spreadsheetStream, templateFileStream, 3, 3); PackageBuilder builder = new PackageBuilder(); builder.addPackageFromDrl(new StringReader(drl)); RuleBase templateRuleBase = RuleBaseFactory.newRuleBase(); templateRuleBase.addPackage(builder.getPackage()); // create session StatefulSession rulesSession = templateRuleBase.newStatefulSession(); KnowledgeRuntimeLogger rulesLogger = KnowledgeRuntimeLoggerFactory.newConsoleLogger(rulesSession);//<<DOESN'T COMPILE! FactHandle factHandle = rulesSession.insert(myFact); // fire the rules rulesSession.fireAllRules();