com.caplin.keymaster
Class FileLogger

java.lang.Object
  extended by com.caplin.keymaster.FileLogger

public class FileLogger
extends Object

This class sets up a Logger instance to allow the other classes in the com.caplin.keymaster and examples packages. The class is supplied a Level and a file name to store the log in. These properties are currently retrieved from a properties file which is passed to the constructor.

The logger name is standardised across the whole package. This is achieved by using a static class member KeyMaster which all classes call to set the logger name.

As part of the default behaviour of Logger any Level.INFO, Level.SEVERE and Level.WARNING messages will additionally be written to the console as well as to the underlying file. All non-error execution messages are set to Level.FINER

If the class fails to instantiate correctly due to an error caused by the user, execution will not be effected apart from the lack of log messages. However if the user is using a Java Virtual Machine older than 1.4 then execution will fail as the Logger class requires this as a mimimum.


Constructor Summary
FileLogger(Properties props)
          Constructor to set the name, level and file handler for the logger.
FileLogger(String loggerFile, String logLevel)
           This constructor was added to the class to allow StandardKeyMaster class to create an instance.
 
Method Summary
 void closeLog()
          Send the log to file associated with it.
 void flush()
           Flush any messages held in the logger to the associated filestream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileLogger

public FileLogger(Properties props)
Constructor to set the name, level and file handler for the logger.

Parameters:
props - Properties file passed from either KeyGenerator or servlet class.
Throws:
IllegalArgumentException - If the properties file doesn't exist then throw this exception.

FileLogger

public FileLogger(String loggerFile,
                  String logLevel)

This constructor was added to the class to allow StandardKeyMaster class to create an instance. The servlet doesn't use a properties file so this method was added. It performs the same functionality of the constructor with the properties file passed to it.

Parameters:
loggerFile - Name of the file to be associated with the log
logLevel - The level that the log will record. Should be set to Level.ALL during testing or design. Then set to Level.WARNING or Level.SEVERE when released.
Method Detail

closeLog

public void closeLog()

Send the log to file associated with it. Then close the file. Before doing anything make sure the class has been initialised.


flush

public void flush()

Flush any messages held in the logger to the associated filestream.



Please send bug reports and comments to Caplin support