Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.util.logging

Class MemoryHandler

java.lang.Object
|
+--java.util.logging.Handler
   |
   +--java.util.logging.MemoryHandler


public class MemoryHandler

extends Handler

A MemoryHandler maintains a circular buffer of log records.

Configuration: Values of the subsequent LogManager properties are taken into consideration when a MemoryHandler is initialized. If a property is not defined, or if it has an invalid value, a default is taken without an exception being thrown.

Author:

Constructor Summary

MemoryHandler()

Constructs a MemoryHandler for keeping a circular buffer of LogRecords; the initial configuration is determined by the LogManager properties described above.
MemoryHandler(java.util.logging.Handler target, int size, java.util.logging.Level pushLevel)

Constructs a MemoryHandler for keeping a circular buffer of LogRecords, given some parameters.

Method Summary

voidclose()

Closes this MemoryHandler and its associated target handler, discarding the contents of the memory buffer.
voidflush()

Forces any data that may have been buffered by the target Handler to the underlying output device, but does not push the contents of the circular memory buffer to the target handler.
java.util.logging.LevelgetPushLevel()

Returns the push level threshold for this Handler.
voidpublish(java.util.logging.LogRecord record)

Stores a LogRecord in a fixed-size circular buffer, provided the record passes all tests for being loggable.
voidpush()

Pushes the contents of the memory buffer to the target Handler and clears the buffer.
voidsetPushLevel(java.util.logging.Level pushLevel)

Sets the push level threshold for this Handler.

Constructor Details

MemoryHandler

public MemoryHandler()

Constructs a MemoryHandler for keeping a circular buffer of LogRecords; the initial configuration is determined by the LogManager properties described above.


MemoryHandler

public MemoryHandler(java.util.logging.Handler target, int size, java.util.logging.Level pushLevel)

Constructs a MemoryHandler for keeping a circular buffer of LogRecords, given some parameters. The values of the other parameters are taken from LogManager properties, as described above.

Parameters:

Throws:


Method Details

close

public void close()

Closes this MemoryHandler and its associated target handler, discarding the contents of the memory buffer. However, any data that may have been buffered by the target Handler is forced to the underlying output device.

As soon as close has been called, a Handler should not be used anymore. Attempts to publish log records, to flush buffers, or to modify the Handler in any other way may throw runtime exceptions after calling close.

In case of an I/O failure, the ErrorManager of the associated target Handler will be informed, but the caller of this method will not receive an exception.

Throws:

See Also:


flush

public void flush()

Forces any data that may have been buffered by the target Handler to the underlying output device, but does not push the contents of the circular memory buffer to the target handler.

In case of an I/O failure, the ErrorManager of the target Handler will be notified, but the caller of this method will not receive an exception.

See Also:


getPushLevel

public Level getPushLevel()

Returns the push level threshold for this Handler. When a record is published whose severity level is greater than or equal to the pushLevel of this MemoryHandler, the #push() method will be invoked for pushing the buffer contents to the target Handler.

Returns:


publish

public void publish(java.util.logging.LogRecord record)

Stores a LogRecord in a fixed-size circular buffer, provided the record passes all tests for being loggable. If the buffer is full, the oldest record will be discarded.

If the record has a severity level which is greater than or equal to the pushLevel of this MemoryHandler, the #push() method will be invoked for pushing the buffer contents to the target Handler.

Most applications do not need to call this method directly. Instead, they will use use a Logger, which will create LogRecords and distribute them to registered handlers.

Parameters:


push

public void push()

Pushes the contents of the memory buffer to the target Handler and clears the buffer. Note that the target handler will discard those records that do not satisfy its own severity level threshold, or that are not considered loggable by an installed Filter.

In case of an I/O failure, the ErrorManager of the target Handler will be notified, but the caller of this method will not receive an exception.


setPushLevel

public void setPushLevel(java.util.logging.Level pushLevel)

Sets the push level threshold for this Handler. When a record is published whose severity level is greater than or equal to the pushLevel of this MemoryHandler, the #push() method will be invoked for pushing the buffer contents to the target Handler.

Parameters:

Throws: