1 *java.util.logging.MemoryHandler* *MemoryHandler* Handler that buffers requests
3 public class MemoryHandler
4 extends |java.util.logging.Handler|
6 |java.util.logging.MemoryHandler_Description|
7 |java.util.logging.MemoryHandler_Fields|
8 |java.util.logging.MemoryHandler_Constructors|
9 |java.util.logging.MemoryHandler_Methods|
11 ================================================================================
13 *java.util.logging.MemoryHandler_Constructors*
14 |java.util.logging.MemoryHandler()|Create a MemoryHandler and configure it base
15 |java.util.logging.MemoryHandler(Handler,int,Level)|Create a MemoryHandler.
17 *java.util.logging.MemoryHandler_Methods*
18 |java.util.logging.MemoryHandler.close()|Close the Handler and free all associa
19 |java.util.logging.MemoryHandler.flush()|Causes a flush on the target Handler.
20 |java.util.logging.MemoryHandler.getPushLevel()|Get the pushLevel.
21 |java.util.logging.MemoryHandler.isLoggable(LogRecord)|Check if this Handler wo
22 |java.util.logging.MemoryHandler.publish(LogRecord)|Store a LogRecord in an int
23 |java.util.logging.MemoryHandler.push()|Push any buffered output to the target
24 |java.util.logging.MemoryHandler.setPushLevel(Level)|Set the pushLevel.
26 *java.util.logging.MemoryHandler_Description*
28 Handler that buffers requests in a circular buffer in memory.
30 Normally this Handler simply stores incoming LogRecords into its memory buffer
31 and discards earlier records. This buffering is very cheap and avoids
32 formatting costs. On certain trigger conditions, the MemoryHandler will push
33 out its current buffer contents to a target Handler, which will typically
34 publish them to the outside world.
36 There are three main models for triggering a push of the buffer:
38 An incoming LogRecord has a type that is greater than a pre-defined level, the
41 An external class calls the push method explicitly.
43 A subclass overrides the log method and scans each incoming LogRecord and calls
44 push if a record matches some desired criteria.
46 Configuration: By default each MemoryHandler is initialized using the following
47 LogManager configuration properties. If properties are not defined (or have
48 invalid values) then the specified default values are used. If no default value
49 is defined then a RuntimeException is thrown.
51 java.util.logging.MemoryHandler.level specifies the level for the Handler
52 (defaults to Level.ALL). java.util.logging.MemoryHandler.filter specifies the
53 name of a Filter class to use (defaults to no Filter).
54 java.util.logging.MemoryHandler.size defines the buffer size (defaults to
55 1000). java.util.logging.MemoryHandler.push defines the pushLevel (defaults to
56 level.SEVERE). java.util.logging.MemoryHandler.target specifies the name of the
57 target Handler class. (no default).
60 *java.util.logging.MemoryHandler()*
62 public MemoryHandler()
64 Create a MemoryHandler and configure it based on LogManager configuration
68 *java.util.logging.MemoryHandler(Handler,int,Level)*
71 java.util.logging.Handler target,
73 java.util.logging.Level pushLevel)
75 Create a MemoryHandler.
77 The MemoryHandler is configured based on LogManager properties (or their
78 default values) except that the given pushLevel argument and buffer size
81 target - the Handler to which to publish output.
82 size - the number of log records to buffer (must be greater than zero)
83 pushLevel - message level to push on
85 *java.util.logging.MemoryHandler.close()*
88 throws |java.lang.SecurityException|
90 Close the Handler and free all associated resources. This will also close the
94 *java.util.logging.MemoryHandler.flush()*
98 Causes a flush on the target Handler.
100 Note that the current contents of the MemoryHandler buffer are not written out.
101 That requires a "push".
104 *java.util.logging.MemoryHandler.getPushLevel()*
106 public synchronized |java.util.logging.Level| getPushLevel()
111 Returns: the value of the pushLevel
112 *java.util.logging.MemoryHandler.isLoggable(LogRecord)*
114 public boolean isLoggable(java.util.logging.LogRecord record)
116 Check if this Handler would actually log a given LogRecord into its internal
119 This method checks if the LogRecord has an appropriate level and whether it
120 satisfies any Filter. However it does not check whether the LogRecord would
121 result in a "push" of the buffer contents. It will return false if the
126 Returns: true if the LogRecord would be logged.
127 *java.util.logging.MemoryHandler.publish(LogRecord)*
129 public synchronized void publish(java.util.logging.LogRecord record)
131 Store a LogRecord in an internal buffer.
133 If there is a Filter, its isLoggable method is called to check if the given log
134 record is loggable. If not we return. Otherwise the given record is copied into
135 an internal circular buffer. Then the record's level property is compared with
136 the pushLevel. If the given level is greater than or equal to the pushLevel
137 then push is called to write all buffered records to the target output Handler.
139 record - description of the log event. A null record is silently ignored and is not
142 *java.util.logging.MemoryHandler.push()*
144 public synchronized void push()
146 Push any buffered output to the target Handler.
148 The buffer is then cleared.
151 *java.util.logging.MemoryHandler.setPushLevel(Level)*
153 public void setPushLevel(java.util.logging.Level newLevel)
154 throws |java.lang.SecurityException|
156 Set the pushLevel. After a LogRecord is copied into our internal buffer, if its
157 level is greater than or equal to the pushLevel, then push will be called.
159 newLevel - the new value of the pushLevel