It is important for a library which aims to integrate as a software component in an existing system to provide accurate and concise execution traces, adapted to the situation (development, qualification, production). It also has to integrate with the log system adopted by the master software without being intrusive, meaning without the necessity of third party library.
To meet these specifications, MRules has chosen to develop an internal log interface, redirecting log messages to an external interface.
Accepted external log interfaces cover the majority of applications. These are, in order of priority, slf4j, log4j and JDK-integrated java.util.logging library. No configuration is necessary: a search of available Logger is performed at initialization.
Regarding the verbosity of logs, different levels (DEBUG, INFO, WARN, and ERROR) will give different information, corresponding to the needs of the teams having to interpret them.
Finally, all the execution logs of a given RuleSet instance are grouped within the same logger, in order to easily trace the different stages of compilation or execution.
Compilation, optimization and Execution have three distinct loggers in order to be able to configure their log level independently. Logger names are build as follows by default:
- com.massa.mrules.set.COMPILE.<RuleSet name>
- com.massa.mrules.set.OPTIMIZE.<RuleSet name>
- com.massa.mrules.set.EXECUTE.<RuleSet name>
As the logger is hold by the context, it is perfectly possible to override its default name for a given execution to trace it precisely.
Here is an extract of log4j configuration for tracing the execution of a particular rule engine instance if needed:
#Ruleset instance with logger name « ruleSetName » will have a TRACE log level.
log4j.logger.com.massa.mrules.set.EXECUTE.ruleSetName = TRACE, console
log4j.additivity.com.massa.mrules.set.EXECUTE.ruleSetName = false
log4j.logger.com.massa.mrules.set.OPTIMIZE.ruleSetName = TRACE, console
log4j.additivity.com.massa.mrules.set.OPTIMIZE.ruleSetName = false
log4j.logger.com.massa.mrules.set.COMPILE.ruleSetName = TRACE, console
log4j.additivity.com.massa.mrules.set.COMPILE.ruleSetName = false
#All other Ruleset instances will have a WARN log level.
log4j.logger.com.massa.mrules.set= WARN, console
#All other MRules logs with level INFO and above will be printed.
log4j.logger.com.massa.mrules = INFO, console
log4j.additivity.com.massa.mrules = false
#This deactivates traces for property access and conversion.
log4j.logger.com.massa= ERROR, console
log4j.additivity.com.massa = false