|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.util.logging.Handler
![]()
![]()
![]()
java.util.logging.MemoryHandler
public class MemoryHandler

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 | |
|---|---|
MemoryHandler
Create a MemoryHandler and configure it based on LogManager configuration properties. |
|
MemoryHandler
Create a MemoryHandler. |
|
| Method Summary | |
|---|---|
void |
close
Close the Handler and free all associated resources. |
void |
flush
Causes a flush on the target Handler. |
Level |
getPushLevel
Get the pushLevel. |
boolean |
isLoggable
Check if this Handler would actually log a given LogRecord into its internal buffer. |
void |
publish
Store a LogRecord in an internal buffer. |
void |
push
Push any buffered output to the target Handler. |
void |
setPushLevel
Set the pushLevel. |
Methods inherited from class java.util.logging.Handler ![]() |
|---|
getEncoding |
Methods inherited from class java.lang.Object ![]() |
|---|
clone |
| Constructor Detail |
|---|

public MemoryHandler()

public MemoryHandler(Handler![]()
![]()
target, int size, Level
![]()
![]()
pushLevel)
The MemoryHandler is configured based on LogManager properties (or their default values) except that the given pushLevel argument and buffer size argument are used.
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
IllegalArgumentException

- is size is <= 0| Method Detail |
|---|

public void publish(LogRecord![]()
![]()
record)
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.
publish

in class Handler

record - description of the log event. A null record is
silently ignored and is not published

public void push()
The buffer is then cleared.

public void flush()
Note that the current contents of the MemoryHandler buffer are not written out. That requires a "push".
flush

in class Handler


public void close()
throws SecurityException

close

in class Handler

SecurityException

- if a security manager exists and if
the caller does not have LoggingPermission("control").

public void setPushLevel(Level![]()
![]()
newLevel) throws SecurityException
![]()
![]()
newLevel - the new value of the pushLevel
SecurityException

- if a security manager exists and if
the caller does not have LoggingPermission("control").

public Level![]()
![]()
getPushLevel()

public boolean isLoggable(LogRecord![]()
![]()
record)
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.
isLoggable

in class Handler

record - a LogRecord
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||