ILOG JRules User Guide > Managing Rule Execution Server > Tasks > Monitoring Rule Execution Server Events > Setting a Logger to a J2SE Rule Session

It is relatively easy to set a logger to a J2SE rule session.

To attach a logger to a stateless rule session instance

FileOutputStream outFile = ...;
PrintWriter loggerPrinter = ...;
ruleSessionProvider = new IlrRuleSessionProviderFactory.
   Builder(IlrRuleSessionProviderFactory.
   J2SERuleSessionProvider).setLogger(loggerPrinter).build();

Using the rule engine API (IlrContext) the Context.out stream is automatically attached to System.out in a J2SE application. When you use the rule session API this output stream is captured by the session. It is available in the IlrSessionExecutionResult as a string as it is considered part of the execution result. The stream can be obtained using the getOutputString method.

On the other hand the logger that you pass when you create a rule session provider is used by the Execution Unit (XU) for logging its activity. The Context.out is not directed to this stream.

Related Concepts

Execution
Rule Execution Server Management Model

Related Tasks

Setting the Granularity of Log Messages
Finding the Cause of an Improper Rule Execution Server Configuration
Execution Events Monitoring
Management Events Monitoring
Receiving Notification of Rule Engine Events Using the API

Related Samples and Tutorials

How to Automate Ruleset Management