grace.log
Class FileHandler
java.lang.Object
|
+--grace.log.PrintHandler
|
+--grace.log.FileHandler
- public class FileHandler
- extends PrintHandler
- implements Handler
This kind of PrintHandler writes all of its data into a file. The
file can be specified in the constructor or as Properties.
This Handler has the ability to write a limited length file instead
of a never ending file. This is accomplished by monitoring the
size of the log file and when the file gets to a threshold size,
copy the portion of the file to a temporary file then rename the
temporary file to the original log file name. This may cause havoc
with a log monitor program that reads the whole log and then waits
to read the asynchonous updates. This type of program will have to
use of event sequence numbers to determine which events it has
already displayed.
Note that currently the events are always appended to the log
file - even between different runs of the logging program. This
means that the user must manually remove the file if he wants the
log to start with a clean file.
The Properties interpreted by this class are:
log.handler.name.url = { file:///abs-path | file:rel-path }
log.handler.name.maxsize = 1000000 | 1000k | 1m
log.handler.name.file = filename this is deprecated
Field Summary |
static java.lang.String |
rcsid
|
Constructor Summary |
FileHandler(java.lang.String filename)
This constructs a FileHandler that prints to the specified
file. |
FileHandler(java.lang.String filename,
int maxKilobytes)
This constructs a FileHandler that prints to the given filename
and limits the size of this file during logging to the given
maxKilobytes. |
FileHandler(java.lang.String prefix,
java.lang.String name)
This constructs a FileHandler that is initialized by
properties. |
Method Summary |
protected void |
cutFileInHalf()
|
protected void |
establishWriter(java.lang.String filename)
This sets up the stream depending on what is given for
filename. |
void |
handle(Event event)
The handle(Event) call is caught here so that the file size can be
trimmed after the event is written. |
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
rcsid
public static final java.lang.String rcsid
FileHandler
public FileHandler(java.lang.String prefix,
java.lang.String name)
throws java.rmi.RemoteException
- This constructs a FileHandler that is initialized by
properties.
FileHandler
public FileHandler(java.lang.String filename)
throws java.rmi.RemoteException
- This constructs a FileHandler that prints to the specified
file.
- Parameters:
filename
- to which to print log messages
FileHandler
public FileHandler(java.lang.String filename,
int maxKilobytes)
throws java.rmi.RemoteException
- This constructs a FileHandler that prints to the given filename
and limits the size of this file during logging to the given
maxKilobytes. It does this by monitoring the size of the file,
copying a portion the file to a temporary file if it exceeds
maxKilobytes, and copying back to the log file.
establishWriter
protected void establishWriter(java.lang.String filename)
- This sets up the stream depending on what is given for
filename. Filename can be a absoluate path, a relative path,
or '-' for standard out. If there is any problem with the
opening the file, standard out is used.
handle
public void handle(Event event)
- The handle(Event) call is caught here so that the file size can be
trimmed after the event is written.
- Specified by:
- handle in interface Handler
- Overrides:
- handle in class PrintHandler
cutFileInHalf
protected void cutFileInHalf()
main
public static void main(java.lang.String[] args)