2

I'm using Drools 5.4.0.Final For logging I'm using logback in my application.

I tried to add update my logback.xml with

<logger name="org.drools" level="debug"/>

But I see nothing in my logs concerning Drools. I would expect to see so my lines of logs concerning the drools initialization.

Frederic Close
  • 9,389
  • 6
  • 56
  • 67

2 Answers2

3

You can pass the LOGGER to the StatefulKnowledgeSession

    private static final Logger LOGGER = LoggerFactory.getLogger(Example.class);
    private transient StatefulKnowledgeSession ksession;
    .
    .
    .
    ksession.setGlobal("logger", LOGGER);

and in your DRL file, you have to define global org.slf4j.Logger logger and then you can use the logger in your rules.

cgalleguillosm
  • 344
  • 3
  • 7
2

Drools 5.4.0.Final does not support any logging framework natively. The next version, Drools 5.5.0.Beta1, will. It will also be documented in the manual how to use it. See this issue for more info.

Drools 5.5.0.Beta1 will log to slf4j-api, so you can logback, log4j, jdk-logging, slf4j-simple, ... You still need to explicitly call KnowledgeRuntimeLoggerFactory.newConsoleLogger() and add that to the event listeners.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • Thanks, I saw your message on the committer mailing list (Logging: howto show logging + best practices of slf4j) but didn't know in which version this will be available. With version 5.4, how are you supposed to monitor / debug drools ? – Frederic Close Aug 21 '12 at 09:04
  • @FredClose Not sure, but with KnowledgeRuntimeLoggerFactory.newFile... you can do some monitoring already. Ask in the mailing list and specify what exactly you want to see in the logging. – Geoffrey De Smet Aug 21 '12 at 14:44