[rules-users] Anyway to get Failed Reason for Failed Rule?

FrankVhh frank.vanhoenshoven at agserv.eu
Fri Aug 10 09:25:29 EDT 2012


Hi there,

Just a minor remark.

If you prefer this way of working, do not add the log as a Fact. Add it as a
global. Otherwise, it would clutter the rete tree and slow down the
execution.

Unless you want to use the RuleLog to control the further execution, that
is.

Regards,
Frank


jasonxzhong wrote
> 
> A simple solution is to pass in a string list and for each rule that is
> fired, append the rule name to the list. Example
> 
> In your Java code declare:
> class RuleLog {
> 	List log = new ArrayList();
> 	public void add(String logEntry) {
> 		log.add(logEntry);
> 	}	
> ...
> }
> 
> Then insert an instance of RuleLog as a fact to the rules engine. The log
> entries generated can be retrieved after the rule session is completed.
> 
> In your rule:
> 
> rule "foo"
>    when 
> 	....
> 	logger: RuleLog()
>    Then
> 	// this will add the current rule name to the log when this rule is fired
> 	logger.add(drools.getRule().getName())
> 	...
> end
> 
> Jason
> 
> 
> 
> 
> -----Original Message-----
> From: rules-users-bounces at .jboss [mailto:rules-users-bounces at .jboss] On
> Behalf Of Rana
> Sent: Thursday, August 09, 2012 5:00 PM
> To: rules-users at .jboss
> Subject: Re: [rules-users] Anyway to get Failed Reason for Failed Rule?
> 
> Hi Davide, your second guess is right. Sorry I should have said failed
> condition.
> 
> I wanted to know which rule got fired and which one did not (because the
> condition failed in when clause).
> 
> I wanted to know those, because we have requirement which asks for what
> are
> the rules which have passed and failed copnditions, so that we can make
> some
> decisions.
> 
> Also, I wanted to know that in a rule
> 
> rule "name"
> when
>     //condition
> then
>    //consequence
> end
> 
> when the condition is failed will the rule goes to consequence or not.  (I
> am fairely new to Drools. sorry).
> 
> Thanks.
> 
> 
> 
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Anyway-to-get-Failed-Reason-for-Failed-Rule-tp4019070p4019077.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at .jboss
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> _______________________________________________
> rules-users mailing list
> rules-users at .jboss
> https://lists.jboss.org/mailman/listinfo/rules-users
> 




--
View this message in context: http://drools.46999.n3.nabble.com/Anyway-to-get-Failed-Reason-for-Failed-Rule-tp4019070p4019088.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list