Search code examples
jboss7.xdroolsmvel

Drools unable to resolve logger


I have a rule similar to the below one. When I use logger.debug in THEN sections of the rule, it works and not while I use it in WHEN sections.

Any ideas why?

package com.util;
import com.rulemodel.*;
global org.slf4j.Logger logger;


rule "My rule"
dialect "mvel"
when
    $t : TransxnFact()
    $obj : BizObj((acType.equalsIgnoreCase("Check") && $t.getSubType().equalsIgnoreCase("TWO")) )   

then
  insert( new XXFact($t.getId() ) )
  logger.debug($t.getId()+ "fact inserted")
     logger.debug($x.getAcType())

end

I get the following error - Unable to resolve ObjectType 'logger.debug'


Solution

  • In 'when' block you can define just condition. If you want to capture facts inserted in kiesession then you can use RuleRuntimeEventListener.