[rules-users] Rules trace questions

Wolfgang Laun wolfgang.laun at gmail.com
Wed Nov 24 08:16:14 EST 2010


Logging activation *creations* may not be a good idea if you want to log
rule firings. Creations happen when facts are inserted/updated/retracted,
and the log may not even reflect what will really fire, since pending
activations
might even be removed. Even if they all fire, the order of creations can be
anything compared to firings.

Log entries are written sequentially in chronological order.

Triggering the writing of a log to disk by inserting a fact (Output) may
cause confusion since there's no guarantee that the firing according to
the new Output() will happen *next*. Other activations may result in firings
in between.

A good way for creating a log is to finish it from Java code, after return from
fireAllRules().

Finally, you are using classes from the unstable part. AFAIK, the current
stable class to use is org.drools.logger.KnowledgeRuntimeLogger. This
has only a close() method, and it will not continue to log. (But this
is consistent
with the previous paragraph.)

-W

On 24 November 2010 12:12, Anais Martinez <amartinez at iti.upv.es> wrote:
>
> Hello.
>
> I'm trying to get the rules trace in execution by using
> WorkingMemoryFileLogger. I am using the Hello word example, and I call the
> WorkingMemoryFileLogger.wirteToDisk() in the RHS of rules. My modified drl
> file is:
>
> import com.sample.DroolsTest.Message;
>
> global org.drools.audit.WorkingMemoryFileLogger rulesLogger
>
> declare Output
>        @role (event)
> end
>
> rule "Hello World"
>        when
>                m : Message( status == Message.HELLO, myMessage : message )
>        then
>                System.out.println( myMessage + ": Hello message" );
>                m.setMessage( myMessage );
>                m.setStatus( Message.GOODBYE );
>                update( m );
> end
>
> rule "GoodBye"
>        when
>                Message( status == Message.GOODBYE, myMessage : message )
>        then
>                System.out.println( myMessage + ": Goodbye message" );
>                Output o= new Output();
>                insert(s);
> end
>
> rule "log trace"
>        when
>                o:Output( )
>        then
>                System.out.println("Loggin trace");
>                rulesLogger.writeToDisk();
> end
>
> I have filtered the logger to see only LogEvent.ACTIVATION_CREATED, and I
> set the global rulesLogger in Main(). If I insert 2 messages, 2 "event.log"
> files and one "test.log" appears. I have several questions (sorry if I say
> nonsense):
>
> First. How do I read the trace for each fire of "rule to log trace"? I mean,
> the trace for "rule to log trace" is written forward (from event
> insertion/updating/removing to "log trace" activation) or backward (from
> "log trace" activation to event insertion/updating/removing)?
>
> Second. Each event.log appears in each "log trace" activation because I am
> writing the trace in the RHS. Am I right? Can I use that in order to read
> the trace for each individual activation of "log trace"?
>
> Third. I only allow LogEvent.ACTIVATION_CREATED, but some ObjectLogEvent
> appear in the test.log file, but not in the event.log files. Why?
>
> Thanks in advance.
>
> --
> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-trace-questions-tp1960008p1960008.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list