Name

MemoryHandler

Synopsis

A MemoryHandler stores LogRecord objects in a fixed-sized buffer in memory. When the buffer fills up, it discards the oldest record one each time a new record arrives. It maintains a reference to another Handler object, and whenever the push( ) method is called, or whenver a LogRecord arrives with a level at or higher than the pushLevel threshold, it “pushes” all of buffered LogRecord objects to that other Handler object, which typically formats and outputs them to some appropriate destination. Because MemoryHandler never outputs log records itself, it does not use the formatter or encoding properties inherited from its superclass.

When you create a MemoryHandler, you can specify the target Handler object, the size of the in-memory buffer, and the value of the pushLevel property, or you can omit these constructor arguments and rely on system-wide defaults obtained with LogManager.getProperty( ). MemoryHandler also uses LogManager.getProperty( ) to obtain initial values for the level and filter properties inherited from Handler. The table below lists these properties, as well as the target, size, and pushLevel constructor arguments, the value passed to getProperty( ), and the default value used if getProperty( ) returns null. See Handler for further details.

Property or argument

LogManager property name

Default

level

java.util.logging.MemoryHandler.level

Level.ALL

filter

java.util.logging.MemoryHandler.filter

null

target

java.util.logging.MemoryHandler.target ...

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.