consciouscode.logging
Class FileLog
java.lang.Object
consciouscode.logging.AbstractLog
consciouscode.logging.PrintLog
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.
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. |
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 |
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:
- the existing "global2.log" is removed,
- "global1.log" is renamed to "global2.log",
- "global.log" is renamed to "global1.log", and
- a new file "global.log" is created to collect log messages.
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
getFile
public File getFile()
getBackupCount
public int getBackupCount()
getPath
public String getPath()
Copyright © 2001–2012
Todd V. Jonker. All Rights Reserved.