This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.util.logging
class MemoryHandler

java.lang.Object extended by java.util.logging.Handler extended by java.util.logging.MemoryHandler

public class MemoryHandler
extends Handler

Handler that buffers requests in a circular buffer in memory.

Normally this Handler simply stores incoming LogRecords into its memory buffer and discards earlier records. This buffering is very cheap and avoids formatting costs. On certain trigger conditions, the MemoryHandler will push out its current buffer contents to a target Handler, which will typically publish them to the outside world.

There are three main models for triggering a push of the buffer:

Configuration: By default each MemoryHandler is initialized using the following LogManager configuration properties. If properties are not defined (or have invalid values) then the specified default values are used. If no default value is defined then a RuntimeException is thrown.


Constructor Summary

          Create a MemoryHandler and configure it based on LogManager configuration properties.
MemoryHandler(Handler target, int size, Level pushLevel)

          Create a MemoryHandler.
 
Method Summary
 void

          Close the Handler and free all associated resources.
 void

          Causes a flush on the target Handler.
 Level

          Get the pushLevel.
 boolean

          Check if this Handler would actually log a given LogRecord into its internal buffer.
 void

          Store a LogRecord in an internal buffer.
 void

          Push any buffered output to the target Handler.
 void
setPushLevel(Level newLevel)

          Set the pushLevel.
 
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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryHandler

public MemoryHandler()
Create a MemoryHandler and configure it based on LogManager configuration properties.


MemoryHandler

public MemoryHandler(Handler target,
                     int size,
                     Level pushLevel)
Create a MemoryHandler.

The MemoryHandler is configured based on LogManager properties (or their default values) except that the given pushLevel argument and buffer size argument are used.

Parameters:
target - the Handler to which to publish output.
size - the number of log records to buffer (must be greater than zero)
pushLevel - message level to push on
Method Detail

close

public void close()
           throws SecurityException
Close the Handler and free all associated resources. This will also close the target Handler.

Overrides:
close in class Handler
Throws:
SecurityException - if a security manager exists and if the caller does not have LoggingPermission("control").

flush

public void flush()
Causes a flush on the target Handler.

Note that the current contents of the MemoryHandler buffer are not written out. That requires a "push".

Overrides:
flush in class Handler

getPushLevel

public synchronized Level getPushLevel()
Get the pushLevel.

Returns:
the value of the pushLevel

isLoggable

public boolean isLoggable(LogRecord record)
Check if this Handler would actually log a given LogRecord into its internal buffer.

This method checks if the LogRecord has an appropriate level and whether it satisfies any Filter. However it does not check whether the LogRecord would result in a "push" of the buffer contents. It will return false if the LogRecord is Null.

Overrides:
isLoggable in class Handler
Parameters:
record - a LogRecord
Returns:
true if the LogRecord would be logged.

publish

public synchronized void publish(LogRecord record)
Store a LogRecord in an internal buffer.

If there is a Filter, its isLoggable method is called to check if the given log record is loggable. If not we return. Otherwise the given record is copied into an internal circular buffer. Then the record's level property is compared with the pushLevel. If the given level is greater than or equal to the pushLevel then push is called to write all buffered records to the target output Handler.

Overrides:
publish in class Handler
Parameters:
record - description of the log event. A null record is silently ignored and is not published

push

public synchronized void push()
Push any buffered output to the target Handler.

The buffer is then cleared.


setPushLevel

public void setPushLevel(Level newLevel)
                  throws SecurityException
Set the pushLevel. After a LogRecord is copied into our internal buffer, if its level is greater than or equal to the pushLevel, then push will be called.

Parameters:
newLevel - the new value of the pushLevel
Throws:
SecurityException - if a security manager exists and if the caller does not have LoggingPermission("control").


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.