Package org.drools.kiesession.audit
Class WorkingMemoryFileLogger
- java.lang.Object
-
- org.drools.kiesession.audit.WorkingMemoryLogger
-
- org.drools.kiesession.audit.WorkingMemoryFileLogger
-
- All Implemented Interfaces:
EventListener,org.kie.api.event.kiebase.KieBaseEventListener,org.kie.api.event.process.ProcessEventListener,org.kie.api.event.rule.AgendaEventListener,org.kie.api.event.rule.RuleRuntimeEventListener,org.kie.api.logger.KieRuntimeLogger
- Direct Known Subclasses:
ThreadedWorkingMemoryFileLogger
public class WorkingMemoryFileLogger extends WorkingMemoryLogger implements org.kie.api.logger.KieRuntimeLogger
A logger of events generated by a working memory. It stores its information in a file that can be specified. All the events logged are written to the file when the writeToDisk() method is invoked. The log will contain all the events logged serialized to XML using XStream. Every time a new logger is created, the old event log will be overwritten. TODO: make this class more scalable, for example - logging to several files if log becomes too large - automatically write updates to file at certain time intervals - ...
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_EVENTS_IN_MEMORYprotected static org.slf4j.Loggerloggerprotected booleanterminate
-
Constructor Summary
Constructors Constructor Description WorkingMemoryFileLogger()WorkingMemoryFileLogger(org.drools.core.WorkingMemory workingMemory)Creates a new WorkingMemoryFileLogger for the given working memory.WorkingMemoryFileLogger(org.kie.api.event.KieRuntimeEventManager session)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidlogEventCreated(LogEvent logEvent)This method is invoked every time a new log event is created.voidreadExternal(ObjectInput in)voidsetFileName(String fileName)Sets the name of the file the events are logged in.voidsetMaxEventsInMemory(int maxEventsInMemory)Sets the maximum number of log events that are allowed in memory.voidsetSplit(boolean split)voidstop()voidwriteExternal(ObjectOutput out)voidwriteToDisk()All events in the log are written to file.-
Methods inherited from class org.drools.kiesession.audit.WorkingMemoryLogger
addFilter, afterFunctionRemoved, afterKieBaseLocked, afterKieBaseUnlocked, afterKiePackageAdded, afterKiePackageRemoved, afterMatchFired, afterNodeLeft, afterNodeTriggered, afterProcessAdded, afterProcessCompleted, afterProcessRemoved, afterProcessStarted, afterRuleAdded, afterRuleFlowGroupActivated, afterRuleFlowGroupDeactivated, afterRuleRemoved, afterVariableChanged, agendaGroupPopped, agendaGroupPushed, beforeFunctionRemoved, beforeKieBaseLocked, beforeKieBaseUnlocked, beforeKiePackageAdded, beforeKiePackageRemoved, beforeMatchFired, beforeNodeLeft, beforeNodeTriggered, beforeProcessAdded, beforeProcessCompleted, beforeProcessRemoved, beforeProcessStarted, beforeRuleAdded, beforeRuleFlowGroupActivated, beforeRuleFlowGroupDeactivated, beforeRuleRemoved, beforeVariableChanged, clearFilters, matchCancelled, matchCreated, objectDeleted, objectInserted, objectUpdated, removeFilter
-
-
-
-
Field Detail
-
logger
protected static final transient org.slf4j.Logger logger
-
DEFAULT_MAX_EVENTS_IN_MEMORY
public static final int DEFAULT_MAX_EVENTS_IN_MEMORY
- See Also:
- Constant Field Values
-
terminate
protected boolean terminate
-
-
Constructor Detail
-
WorkingMemoryFileLogger
public WorkingMemoryFileLogger()
-
WorkingMemoryFileLogger
public WorkingMemoryFileLogger(org.drools.core.WorkingMemory workingMemory)
Creates a new WorkingMemoryFileLogger for the given working memory.
-
WorkingMemoryFileLogger
public WorkingMemoryFileLogger(org.kie.api.event.KieRuntimeEventManager session)
-
-
Method Detail
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Overrides:
readExternalin classWorkingMemoryLogger- Throws:
IOExceptionClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Overrides:
writeExternalin classWorkingMemoryLogger- Throws:
IOException
-
setFileName
public void setFileName(String fileName)
Sets the name of the file the events are logged in. No extensions should be given since .log is automatically appended to the file name. The default is an event.log file in the current working directory. This can be a path relative to the current working directory (e.g. "mydir/subDir/myLogFile"), or an absolute path (e.g. "C:/myLogFile").- Parameters:
fileName- The name of the file the events should be logged in.
-
writeToDisk
public void writeToDisk()
All events in the log are written to file. The log is automatically cleared afterwards.
-
setMaxEventsInMemory
public void setMaxEventsInMemory(int maxEventsInMemory)
Sets the maximum number of log events that are allowed in memory. If this number is reached, all events are written to file. The default is 1000.- Parameters:
maxEventsInMemory- The maximum number of events in memory.
-
logEventCreated
public void logEventCreated(LogEvent logEvent)
Description copied from class:WorkingMemoryLoggerThis method is invoked every time a new log event is created. Subclasses should implement this method and store the event, like for example log to a file or database.- Specified by:
logEventCreatedin classWorkingMemoryLogger
-
setSplit
public void setSplit(boolean split)
-
stop
public void stop()
-
close
public void close()
- Specified by:
closein interfaceorg.kie.api.logger.KieRuntimeLogger
-
-