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:

  • An incoming LogRecord has a type that is greater than a pre-defined level, the pushLevel.
  • An external class calls the push method explicitly.
  • A subclass overrides the log method and scans each incoming LogRecord and calls push if a record matches some desired criteria.

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.

  • java.util.logging.MemoryHandler.level specifies the level for the Handler (defaults to Level.ALL).
  • java.util.logging.MemoryHandler.filter specifies the name of a Filter class to use (defaults to no Filter).
  • java.util.logging.MemoryHandler.size defines the buffer size (defaults to 1000).
  • java.util.logging.MemoryHandler.push defines the pushLevel (defaults to level.SEVERE).
  • specifies the name of the target Handler class. (no default).

Public Constructor Summary

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

Public Method Summary

Close the Handler and free all associated resources.
Causes a flush on the target Handler.
synchronized Level
Get the pushLevel.
isLoggable(LogRecord record)
Check if this Handler would actually log a given LogRecord into its internal buffer.
synchronized void
publish(LogRecord record)
Store a LogRecord in an internal buffer.