consciouscode.logging
Class FileLog

java.lang.Object
  extended by consciouscode.logging.AbstractLog
      extended by consciouscode.logging.PrintLog
          extended by consciouscode.logging.FileLog
All Implemented Interfaces:
Log

public class FileLog
extends PrintLog

Log implementation that sends all messages to a file. Additionally, the log can maintain a set of numbered backup files, so that restarting the application doesn't remove all existing logs.


Field Summary
 
Fields inherited from class consciouscode.logging.AbstractLog
DEBUG, ERROR, FATAL, INFO, myLogLevel, NONE, TRACE, WARN
 
Constructor Summary
FileLog(String path)
          Create a new file for logging.
FileLog(String path, int backupCount)
          Create a new file for logging, and maintain a set of earlier logs.
 
Method Summary
 int getBackupCount()
           
 File getFile()
           
 String getPath()
           
 
Methods inherited from class consciouscode.logging.PrintLog
doLog, getTimestampPattern, setPrintWriter, setTimestampPattern
 
Methods inherited from class consciouscode.logging.AbstractLog
debug, debug, doLog, error, error, fatal, fatal, info, info, isDebugEnabled, isErrorEnabled, isFatalEnabled, isInfoEnabled, isTraceEnabled, isWarnEnabled, setLogLevel, trace, trace, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileLog

public FileLog(String path)
        throws IOException
Create a new file for logging.

Parameters:
path - is the (absolute or relative) location of the new log file. If a file already exists there, it is replaced. Any missing directories in the path will be created.
Throws:
IOException

FileLog

public FileLog(String path,
               int backupCount)
        throws IOException
Create a new file for logging, and maintain a set of earlier logs. Backup logs are numbered and rotated each time a similarly-named log is created. For example, if path is "global.log" and backupCount is 2, the following steps are taken: Note that this convention causes the files to be listed from newest to oldest using the normal alphabetical ordering rules.

Parameters:
path - is the (absolute or relative) location of the new log file. Any missing directories in the path will be created.
backupCount - is the number of old log files to keep.
Throws:
IOException
Method Detail

getFile

public File getFile()

getBackupCount

public int getBackupCount()

getPath

public String getPath()


Copyright © 2001–2012 Todd V. Jonker. All Rights Reserved.