Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.logger;
 

The KnowledgeRuntimeLogger uses the comprehensive event system to create an audit log that can be used to log the execution of the session for later inspection, in tools such as the Eclipse audit viewer.

 KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "logdir/mylogfile");
 ....
 logger.close();
 

Don't forget to close the logger when it is no longer needed, so resources can be released.

 
 
Creates a file logger in the current thread. The file is in XML format, suitable for interpretation by Eclipse's Drools Audit View or other tools. Note that while events are written as they happen, the file will not be flushed until it is closed or the underlying file buffer is filled. If you need real time logging then use a Console Logger or a Threaded File Logger.

Parameters:
session
fileName - .log is appended to this.
Returns:
 
                                                        String fileName) {
         return getKnowledgeRuntimeLoggerProvider().newFileLoggersession,
                                                                   fileName );
     }

    
Creates a file logger that executes in a different thread, where information is written on given intervals (in milliseconds). The file is in XML format, suitable for interpretation by Eclipse's Drools Audit View or other tools.

Parameters:
session
fileName - .log is appended to this.
interval - in milliseconds.
Returns:
 
                                                                String fileName,
                                                                int interval) {
         return getKnowledgeRuntimeLoggerProvider().newThreadedFileLoggersession,
                                                                           fileName,
                                                                           interval );
     }

    
Logs events to command line console. This is not in XML format, so it cannot be parsed by other tools, but is in real time and is more human readable.

Parameters:
session
Returns:
 
         return getKnowledgeRuntimeLoggerProvider().newConsoleLoggersession );
     }
 
     private static synchronized void setKnowledgeRuntimeLoggerProvider(KnowledgeRuntimeLoggerFactoryService provider) {
     }
 
     private static synchronized KnowledgeRuntimeLoggerFactoryService getKnowledgeRuntimeLoggerProvider() {
         if (  == null ) {
             loadProvider();
         }
         return ;
     }
 
     @SuppressWarnings("unchecked")
     private static void loadProvider() {
         try {
             Class<KnowledgeRuntimeLoggerFactoryServicecls = (Class<KnowledgeRuntimeLoggerFactoryService>) Class.forName"org.drools.impl.KnowledgeRuntimeLoggerFactoryServiceImpl" );
             setKnowledgeRuntimeLoggerProvidercls.newInstance() );
        } catch ( Exception e ) {
            throw new RuntimeException"Provider org.drools.impl.KnowledgeRuntimeLoggerFactoryServiceImpl could not be set.",
                                                       e );
        }
    }
New to GrepCode? Check out our FAQ X