Hi,
I've just started using JBoss Drools version 6.5.0.Final
in Eclipse Neon.
In the previous versions of JBoss Drools (e.g. 6.3.0.Final) the exemplary code
created in the new project contained the following instruction:
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(kSession, "test");
It resulted in creation of file "test.log", which I could open in Eclipse
in Audit Window which visualised the rule execution (it was very useful for the Drools
demonstration to our students).
The examplary code of version 6.5.0.Final, does not contain this instruction.
I tried using the following command:
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(kSession, "logdir/mylogfile");
but it does not compile, compilation error is:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method newFileLogger(KnowledgeRuntimeEventManager, String) in the type KnowledgeRuntimeLoggerFactory
is not applicable for the arguments (KieSession, String)
This is because in exemplary code, the kSession object is now of type KieSession,
which is not compatible with "newFileLogger" method. I tried casting kSession to
KnowledgeRuntimeEventManager, but it results in cast error.
----
The alternative approach I took was to configure logging using SLF4J,
which I found is now included in JBoss Drools installation.
I attached the following jars to the project:
org.aopache.log4j
org.slf4j,api
org.slf4j.impl.log
And added the file src/main/resources/log4j.properties:
###
# Root logger option
log4j.rootLogger=DEBUG, stdout, file
# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=test.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
###
This resulted in file "test.log" being created, but when I opened it in Audit Window,
the Audit Window showed:
The selected audit log is empty.
The file is not empty, but I suspect it contains an improper format so that it cannot be used in Audit Window.
I can also see that examplary project contains file logback-test.xml, but I'm not sure how to use it.
---
Could you please explain to me how to obtain a proper log file
compatible with the Audit Window of the Eclipse plugin
in Drools 6.5.0.Final?
Thank you very much for your time.
Kind regards,
Freyja.