All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.server.log.LogOutputStream
java.lang.Object
|
+----java.io.OutputStream
|
+----com.sun.server.log.LogOutputStream
- public class LogOutputStream
- extends OutputStream
- implements AlarmHandler
A buffered output stream for writing ASCII text in native text file
format to a file in a "rolling" fasion. The buffer size, filename,
and rollover point are all configurable. Rolling files work by checking
if the rollover point (size of file in bytes) has been exceeded after
every write. If the rollover point is exceeded, the file is closed,
renamed to the filename followed by a ".1" (with all previous files
"shifted down" by one), and a new file is created. If the "shift down"
causes the maximum number of saved files to be exceeded, the oldest
file is deleted.
-
buf
- The buffer where output data is stored.
-
count
- The number of bytes in the buffer.
-
lineSeparator
- The line separator.
-
LogOutputStream(File)
- Creates a new output stream with defaults
-
LogOutputStream(File, long, int)
- Create a new output stream, with no timed flushes
-
LogOutputStream(File, long, int, int)
- Creates a new output stream with rollover, buffer size, and flush time.
-
flush()
- Flushes the output stream.
-
handleAlarm(Alarm)
-
Handle alarm sent for timed flush.
-
write(byte[])
- Writes an array of bytes to the output stream.
-
write(byte[], int, int)
- Writes an array of bytes to the output stream.
-
write(int)
- Writes a byte of data to the output stream.
buf
protected byte buf[]
- The buffer where output data is stored.
count
protected int count
- The number of bytes in the buffer.
lineSeparator
protected static final String lineSeparator
- The line separator.
LogOutputStream
public LogOutputStream(File outfile,
long rollover,
int size,
int flushtime) throws IOException
- Creates a new output stream with rollover, buffer size, and flush time.
- Parameters:
- outfile - the file to write output to.
- rollover - the size of the file before rollover occurs.
0 means never roll over.
- size - the buffer size
- flushtime - the time, in seconds, between flushes of the buffer
to disk. 0 means flush only on full buffer.
LogOutputStream
public LogOutputStream(File outfile) throws IOException
- Creates a new output stream with defaults
- Parameters:
- outfile - the output file
LogOutputStream
public LogOutputStream(File outfile,
long rollover,
int buffer) throws IOException
- Create a new output stream, with no timed flushes
- Parameters:
- outfile - the output file
- rollover - size the file is allowed to grow to
- buffer - size of the output buffer, in bytes
write
public synchronized void write(int b) throws IOException
- Writes a byte of data to the output stream. If the rollover point
is exceeded, the existing file will be rolled over to a new file.
- Parameters:
- b - the byte to be written
- Throws: IOException
- if an I/O error has occurred
- Overrides:
- write in class OutputStream
write
public void write(byte b[]) throws IOException
- Writes an array of bytes to the output stream. If the
rollover point is exceeded, the existing file will be rolled
over to a new file.
- Parameters:
- b - the bytes to be written.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- write in class OutputStream
write
public synchronized void write(byte b[],
int off,
int len) throws IOException
- Writes an array of bytes to the output stream. This method will block
until all the bytes have been written. If the rollover point is
exceeded, the existing file will be rolled over to a new file.
- Parameters:
- b - the bytes to be written
- off - the start offset of the bytes
- len - the number of bytes to write
- Throws: IOException
- if an I/O error has occurred
- Overrides:
- write in class OutputStream
flush
public synchronized void flush() throws IOException
- Flushes the output stream.
- Throws: IOException
- if an I/O error has occurred
- Overrides:
- flush in class OutputStream
handleAlarm
public void handleAlarm(Alarm alarm)
- Handle alarm sent for timed flush. When the AlarmManager calls
this method,
- Parameters:
- alarm - The alarm that fired, causing the method call.
All Packages Class Hierarchy This Package Previous Next Index