Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.util.logging.Handler
java.util.logging.MemoryHandler
public class MemoryHandler
extends Handler
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.
java.util.MemoryHandler.level
- specifies
the initial severity level threshold. Default value:
Level.ALL
.java.util.MemoryHandler.filter
- specifies
the name of a Filter class. Default value: No Filter.java.util.MemoryHandler.size
- specifies the
maximum number of log records that are kept in the circular
buffer. Default value: 1000.java.util.MemoryHandler.push
- specifies the
pushLevel
. Default value:
Level.SEVERE
.java.util.MemoryHandler.target
- specifies the
name of a subclass of Handler
that will be used as the
target handler. There is no default value for this property;
if it is not set, the no-argument MemoryHandler constructor
will throw an exception.Constructor Summary | |
| |
|
Method Summary | |
void |
|
void |
|
Level |
|
void | |
void |
|
void |
|
Methods inherited from class java.util.logging.Handler | |
close , flush , getEncoding , getErrorManager , getFilter , getFormatter , getLevel , isLoggable , publish , reportError , setEncoding , setErrorManager , setFilter , setFormatter , setLevel |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public MemoryHandler()
Constructs aMemoryHandler
for keeping a circular buffer of LogRecords; the initial configuration is determined by theLogManager
properties described above.
public MemoryHandler(Handler target, int size, Level pushLevel)
Constructs aMemoryHandler
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:
target
- the target handler that will receive those log records that are passed on for publication.size
- the number of log records that are kept in the buffer. The value must be a at least one.pushLevel
- the push level threshold for thisMemoryHandler
. When a record is published whose severity level is greater than or equal topushLevel
, thepush()
method will be invoked in order to push the bufffer contents totarget
.
- Throws:
IllegalArgumentException
- ifsize
is negative or zero. The GNU implementation also throws an IllegalArgumentException iftarget
orpushLevel
arenull
, but the API specification does not prescribe what should happen in those cases.
public void close() throws SecurityException
Closes thisMemoryHandler
and its associated target handler, discarding the contents of the memory buffer. However, any data that may have been buffered by the targetHandler
is forced to the underlying output device.As soon as
close
has been called, aHandler
should not be used anymore. Attempts to publish log records, to flush buffers, or to modify theHandler
in any other way may throw runtime exceptions after callingclose
.In case of an I/O failure, the
ErrorManager
of the associated targetHandler
will be informed, but the caller of this method will not receive an exception.
- Throws:
SecurityException
- if a security manager exists and the caller is not granted the permission to control the logging infrastructure.
- See Also:
push()
public void flush()
Forces any data that may have been buffered by the targetHandler
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 targetHandler
will be notified, but the caller of this method will not receive an exception.
- See Also:
push()
public Level getPushLevel()
Returns the push level threshold for thisHandler
. When a record is published whose severity level is greater than or equal to thepushLevel
of thisMemoryHandler
, thepush()
method will be invoked for pushing the buffer contents to the targetHandler
.
- Returns:
- the push level threshold for automatic pushing.
public void publish(LogRecord record)
Stores aLogRecord
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 thisMemoryHandler
, thepush()
method will be invoked for pushing the buffer contents to the targetHandler
.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:
record
- the log event to be published.
public void push()
Pushes the contents of the memory buffer to the targetHandler
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 installedFilter
.In case of an I/O failure, the
ErrorManager
of the targetHandler
will be notified, but the caller of this method will not receive an exception.
public void setPushLevel(Level pushLevel)
Sets the push level threshold for thisHandler
. When a record is published whose severity level is greater than or equal to thepushLevel
of thisMemoryHandler
, thepush()
method will be invoked for pushing the buffer contents to the targetHandler
.
- Parameters:
pushLevel
- the push level threshold for automatic pushing.
- Throws:
SecurityException
- if a security manager exists and the caller is not granted the permission to control the logging infrastructure.NullPointerException
- ifpushLevel
isnull
.