I've added Agenda
and RuleRuntime
event listeners to my stateless KIE session but all outputs are showing as ERROR [stderr] ...
; is it possible to configure the session/listeners to use stdout
and control log levels (preferably INFO
)?
I've seen an almost identical Google Groups question for KIE Execution Server but I'm embedding the drools engine in a Thorntail application.
I'm using stateless KIE Sessions and version 7.23.0.Final
of org.kie.kie-api
, org.kie.kie-cie
, org.drools.drools-core
. An excerpt of the creation of my stateless session is:
KieServices kieServices = KieServices.Factory.get();
KieContainer kieContainer = kieServices.getKieClasspathContainer();
StatelessKieSession statelessKieSession = kieContainer.newStatelessKieSession();
statelessKieSession.addEventListener(new DebugAgendaEventListener());
statelessKieSession.addEventListener(new DebugRuleRuntimeEventListener());
I noticed that one of the constructors on DebugAgendaEventListener and DebugRuleRuntimeEventListener can accept a PrintStream argument, can I use this to replace the default stderr
?
Sample outputs logged to the console are:
ERROR [stderr] (default task-1) ==>[ActivationCreatedEvent: getActivation()=[[ ...]]]
ERROR [stderr] (default task-1) ==>[BeforeActivationFiredEvent: getActivation()=[[...]]]
... Rule fired ...
ERROR [stderr] (default task-1) ==>[AfterActivationFiredEvent: getActivation()=[[ ... ]]]
I don't see why these are logged to stderr
by default, they appear more DEBUG
/TRACE
level information so would like to have them output to stdout
if possible.
The Debug*Listener
(s) in kie-api by default emits to standard error to work regardless of any logging configuration. You can indeed pass a custom PrintStream to override where the emission of message is being printed, by using that constructor.
is it possible to configure the session/listeners to use
stdout
and control log levels (preferablyINFO
)?
You can use Debug*Listener
(s) in package org.drools.core.event
from drools-core
dependency, which by means of SLF4j works already by default in the way you describe, that is emit at info
level by default. Provided that as default practice you have configured logging to emit to standard output, it will work that way out of the box.
These are just some "utility" default implementations; alternatively, you can implement your own Listener(s) to work in the you prefer best.