com.sodius.mdw.core.util.log
Class FileLogger

java.lang.Object
  extended by com.sodius.mdw.core.util.log.AbstractLogger
      extended by com.sodius.mdw.core.util.log.FileLogger
All Implemented Interfaces:
Logger

public class FileLogger
extends AbstractLogger

Outputs log information into a file.

Clients may instantiate or subclass this class.


Constructor Summary
FileLogger(File file)
          Constructs a logger which outputs log information into the specified file.
FileLogger(File file, boolean append)
          Constructs a logger which outputs log information into the specified file.
 
Method Summary
protected  void log(Level level, Object message, Throwable error)
          Appends the specified message and error to the underlying file.
 
Methods inherited from class com.sodius.mdw.core.util.log.AbstractLogger
createMessage, debug, debug, debug, error, error, error, getLevel, info, info, info, isLoggable, setLevel, warning, warning, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileLogger

public FileLogger(File file)
           throws FileNotFoundException
Constructs a logger which outputs log information into the specified file.

If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.

Parameters:
file - the file where to log information.
Throws:
FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.

FileLogger

public FileLogger(File file,
                  boolean append)
           throws FileNotFoundException
Constructs a logger which outputs log information into the specified file.

If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.

Parameters:
file - the file where to log information.
append - if true, then information will be written to the end of the file rather than the beginning.
Throws:
FileNotFoundException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.
Method Detail

log

protected void log(Level level,
                   Object message,
                   Throwable error)
Appends the specified message and error to the underlying file. This default implementation always output information the same way, whatever the log level is.

Specified by:
log in class AbstractLogger
Parameters:
level - the log level (not considered by the implementation).
message - the information to log (usually a String), maybe null.
error - an exception to log, maybe null.